From 635151dc2042d9d85406c144bfb4cde32c394e2f Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 15 Mar 2021 21:10:39 +0100 Subject: [PATCH] sys/pm_layered: use atomic_utils --- sys/pm_layered/pm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/pm_layered/pm.c b/sys/pm_layered/pm.c index 4b7c47b608..260e39fd4c 100644 --- a/sys/pm_layered/pm.c +++ b/sys/pm_layered/pm.c @@ -20,6 +20,7 @@ #include +#include "atomic_utils.h" #include "irq.h" #include "periph/pm.h" #include "pm_layered.h" @@ -42,9 +43,7 @@ static pm_blocker_t pm_blocker = { .val_u32 = PM_BLOCKER_INITIAL }; void pm_set_lowest(void) { - unsigned state = irq_disable(); - pm_blocker_t blocker = pm_blocker; - irq_restore(state); + pm_blocker_t blocker = { .val_u32 = atomic_load_u32(&pm_blocker.val_u32) }; unsigned mode = PM_NUM_MODES; while (mode) { if (blocker.val_u8[mode-1]) { @@ -54,7 +53,7 @@ void pm_set_lowest(void) } /* set lowest mode if blocker is still the same */ - state = irq_disable(); + unsigned state = irq_disable(); if (blocker.val_u32 == pm_blocker.val_u32) { DEBUG("pm: setting mode %u\n", mode); pm_set(mode); @@ -85,9 +84,7 @@ void pm_unblock(unsigned mode) pm_blocker_t pm_get_blocker(void) { - unsigned state = irq_disable(); - pm_blocker_t result = pm_blocker; - irq_restore(state); + pm_blocker_t result = { .val_u32 = atomic_load_u32(&pm_blocker.val_u32) }; return result; }