Skip to content

Commit 9e8e88a

Browse files
gmarullnashif
authored andcommitted
pm: device: add compatibility for force suspend and low power
Add support for FORCE_SUSPEND and LOW_POWER actions. Even though these actions have no clear meaning, they are added for compatibility until their associated states are discussed. Their usage in new code should be discouraged until the associated states are clarified. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 2ccf41a commit 9e8e88a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

include/pm/device.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ enum pm_device_action {
7878
PM_DEVICE_ACTION_RESUME,
7979
/** Turn off. */
8080
PM_DEVICE_ACTION_TURN_OFF,
81+
/** Force suspend. */
82+
PM_DEVICE_ACTION_FORCE_SUSPEND,
83+
/** Low power. */
84+
PM_DEVICE_ACTION_LOW_POWER,
8185
};
8286

8387
/**

subsys/pm/device.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,19 @@ int pm_device_state_set(const struct device *dev,
158158
action = PM_DEVICE_ACTION_RESUME;
159159
break;
160160
case PM_DEVICE_STATE_FORCE_SUSPEND:
161-
__fallthrough;
161+
if (dev->pm->state == state) {
162+
return -EALREADY;
163+
}
164+
165+
action = PM_DEVICE_ACTION_FORCE_SUSPEND;
166+
break;
162167
case PM_DEVICE_STATE_LOW_POWER:
163-
__fallthrough;
168+
if (dev->pm->state == state) {
169+
return -EALREADY;
170+
}
171+
172+
action = PM_DEVICE_ACTION_LOW_POWER;
173+
break;
164174
case PM_DEVICE_STATE_OFF:
165175
if (dev->pm->state == state) {
166176
return -EALREADY;

0 commit comments

Comments
 (0)