pm: device_runtime: use atomic_test_bit

Use `atomic_test_bit` when checking pm flags instead of manually using
bitwise operations.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2022-05-10 14:12:00 +10:00 committed by Carles Cufí
commit 8a2eed6cbd

View file

@ -47,7 +47,7 @@ static int runtime_suspend(const struct device *dev, bool async)
(void)k_mutex_lock(&pm->lock, K_FOREVER);
}
if ((pm->flags & BIT(PM_DEVICE_FLAG_RUNTIME_ENABLED)) == 0U) {
if (!atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_ENABLED)) {
goto unlock;
}
@ -129,7 +129,7 @@ int pm_device_runtime_get(const struct device *dev)
(void)k_mutex_lock(&pm->lock, K_FOREVER);
}
if ((pm->flags & BIT(PM_DEVICE_FLAG_RUNTIME_ENABLED)) == 0U) {
if (!atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_ENABLED)) {
goto unlock;
}
@ -232,7 +232,7 @@ int pm_device_runtime_enable(const struct device *dev)
(void)k_mutex_lock(&pm->lock, K_FOREVER);
}
if ((pm->flags & BIT(PM_DEVICE_FLAG_RUNTIME_ENABLED)) != 0U) {
if (atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_ENABLED)) {
goto unlock;
}
@ -279,7 +279,7 @@ int pm_device_runtime_disable(const struct device *dev)
(void)k_mutex_lock(&pm->lock, K_FOREVER);
}
if ((pm->flags & BIT(PM_DEVICE_FLAG_RUNTIME_ENABLED)) == 0U) {
if (!atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_ENABLED)) {
goto unlock;
}