1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/pm_layered: use atomic_utils

This commit is contained in:
Marian Buschsieweke 2021-03-15 21:10:39 +01:00
parent fd36c626a3
commit 635151dc20
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F

View File

@ -20,6 +20,7 @@
#include <assert.h>
#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;
}