Skip to content

Commit f93778f

Browse files
gmarullcfriedt
authored andcommitted
pm: device: do not allow suspending a turned off device
A device that is turned off should not be suspended. A device that has been turned off can only be resumed. This action is currently forbidden by the "should_suspend" function in the device PM code. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 4a0b5ce commit f93778f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

subsys/pm/device.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ int pm_device_state_set(const struct device *dev,
145145
if ((dev->pm->state == PM_DEVICE_STATE_SUSPENDED) ||
146146
(dev->pm->state == PM_DEVICE_STATE_SUSPENDING)) {
147147
return -EALREADY;
148+
} else if (dev->pm->state == PM_DEVICE_STATE_OFF) {
149+
return -ENOTSUP;
148150
}
149151

150152
action = PM_DEVICE_ACTION_SUSPEND;

0 commit comments

Comments
 (0)