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

Merge pull request #16194 from maribu/pm_layered_atomic_utils

sys/pm_layered: use atomic_utils
This commit is contained in:
Marian Buschsieweke 2021-03-30 15:41:28 +02:00 committed by GitHub
commit 5a7dd703e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}