Skip to content

Commit a245ed2

Browse files
Flavio Ceolincfriedt
authored andcommitted
pm: device: Change atomic flags type
Just using a simple atomic for flags instead of using an array. While is neat using ATOMIC_DEFINE for future proof. The reality is that it brings some problem for the wakeup source implementation that needs to statically initialize it during the device definition. Signed-off-by: Flavio Ceolin <[email protected]>
1 parent 689864e commit a245ed2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/pm/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct pm_device {
9696
/** Device pm enable flag */
9797
bool enable : 1;
9898
/* Device PM status flags. */
99-
ATOMIC_DEFINE(flags, PM_DEVICE_FLAG_COUNT);
99+
atomic_t flags;
100100
/** Device usage count */
101101
uint32_t usage;
102102
/** Device power state */

subsys/pm/device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool pm_device_is_any_busy(void)
184184
devc = z_device_get_all_static(&devs);
185185

186186
for (const struct device *dev = devs; dev < (devs + devc); dev++) {
187-
if (atomic_test_bit(dev->pm->flags, PM_DEVICE_FLAG_BUSY)) {
187+
if (atomic_test_bit(&dev->pm->flags, PM_DEVICE_FLAG_BUSY)) {
188188
return true;
189189
}
190190
}
@@ -194,15 +194,15 @@ bool pm_device_is_any_busy(void)
194194

195195
bool pm_device_is_busy(const struct device *dev)
196196
{
197-
return atomic_test_bit(dev->pm->flags, PM_DEVICE_FLAG_BUSY);
197+
return atomic_test_bit(&dev->pm->flags, PM_DEVICE_FLAG_BUSY);
198198
}
199199

200200
void pm_device_busy_set(const struct device *dev)
201201
{
202-
atomic_set_bit(dev->pm->flags, PM_DEVICE_FLAG_BUSY);
202+
atomic_set_bit(&dev->pm->flags, PM_DEVICE_FLAG_BUSY);
203203
}
204204

205205
void pm_device_busy_clear(const struct device *dev)
206206
{
207-
atomic_clear_bit(dev->pm->flags, PM_DEVICE_FLAG_BUSY);
207+
atomic_clear_bit(&dev->pm->flags, PM_DEVICE_FLAG_BUSY);
208208
}

0 commit comments

Comments
 (0)