From 94647d8e67407993780624f10d700037bf9a5817 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Wed, 15 Dec 2021 12:06:34 -0800 Subject: [PATCH] pm: device: Account state locked in action_run Similar what is done in pm_device_state_set, checking if the power state for a given device in pm_device_action_run is locked. Signed-off-by: Flavio Ceolin --- include/pm/device.h | 1 + subsys/pm/device.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/pm/device.h b/include/pm/device.h index f9412aa4cbc..30837818afc 100644 --- a/include/pm/device.h +++ b/include/pm/device.h @@ -330,6 +330,7 @@ int pm_device_state_get(const struct device *dev, * @retval -EALREADY If device is already at the requested state. * @retval -EBUSY If device is changing its state. * @retval -ENOSYS If device does not support PM. + * @retval -EPERM If device has power state locked. * @retval Errno Other negative errno on failure. */ int pm_device_action_run(const struct device *dev, diff --git a/subsys/pm/device.c b/subsys/pm/device.c index 942bba71906..680e7e23f6c 100644 --- a/subsys/pm/device.c +++ b/subsys/pm/device.c @@ -89,6 +89,10 @@ int pm_device_action_run(const struct device *dev, return -ENOSYS; } + if (pm_device_state_is_locked(dev)) { + return -EPERM; + } + switch (action) { case PM_DEVICE_ACTION_FORCE_SUSPEND: __fallthrough;