Skip to content

Commit 9f6abfc

Browse files
committed
PM: suspend: Use valid_state() consistently
Make valid_state() check if the ->enter callback is present in suspend_ops (only PM_SUSPEND_TO_IDLE can be valid otherwise) and make sleep_state_supported() call valid_state() consistently to validate the states other than PM_SUSPEND_TO_IDLE. While at it, clean up the comment in valid_state(). No expected functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 23f62d7 commit 9f6abfc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

kernel/power/suspend.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,13 @@ EXPORT_SYMBOL_GPL(s2idle_wake);
160160
static bool valid_state(suspend_state_t state)
161161
{
162162
/*
163-
* PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states need low level
164-
* support and need to be valid to the low level
165-
* implementation, no valid callback implies that none are valid.
163+
* The PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states require low-level
164+
* support and need to be valid to the low-level implementation.
165+
*
166+
* No ->valid() or ->enter() callback implies that none are valid.
166167
*/
167-
return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
168+
return suspend_ops && suspend_ops->valid && suspend_ops->valid(state) &&
169+
suspend_ops->enter;
168170
}
169171

170172
void __init pm_states_init(void)
@@ -236,7 +238,7 @@ EXPORT_SYMBOL_GPL(suspend_valid_only_mem);
236238

237239
static bool sleep_state_supported(suspend_state_t state)
238240
{
239-
return state == PM_SUSPEND_TO_IDLE || (suspend_ops && suspend_ops->enter);
241+
return state == PM_SUSPEND_TO_IDLE || valid_state(state);
240242
}
241243

242244
static int platform_suspend_prepare(suspend_state_t state)

0 commit comments

Comments
 (0)