Commit 9684e51cd157607f0727c1550e7df6e31de40808
Committed by
Linus Torvalds
1 parent
e8c9c50269
Exists in
master
and in
20 other branches
power management: force pm_ops.valid callback to be assigned
This patch changes the docs and behaviour from "all states valid" to "no states valid" if no .valid callback is assigned. Users of pm_ops that only need mem sleep can assign pm_valid_only_mem without any overhead, others will require more elaborate callbacks. Now that all users of pm_ops have a .valid callback this is a safe thing to do and prevents things from getting messy again as they were before. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Pavel Machek <pavel@ucw.cz> Looks-okay-to: Rafael J. Wysocki <rjw@sisk.pl> Cc: <linux-pm@lists.linux-foundation.org> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 8 additions and 8 deletions Side-by-side Diff
include/linux/pm.h
... | ... | @@ -125,12 +125,12 @@ |
125 | 125 | * struct pm_ops - Callbacks for managing platform dependent suspend states. |
126 | 126 | * @valid: Callback to determine whether the given state can be entered. |
127 | 127 | * If %CONFIG_SOFTWARE_SUSPEND is set then %PM_SUSPEND_DISK is |
128 | - * always valid and never passed to this call. | |
129 | - * If not assigned, all suspend states are advertised as valid | |
130 | - * in /sys/power/state (but can still be rejected by prepare or enter.) | |
131 | - * Since new states can be added for other platforms, you should | |
132 | - * assign this callback. There is a %pm_valid_only_mem function | |
133 | - * available if you only implemented mem sleep. | |
128 | + * always valid and never passed to this call. If not assigned, | |
129 | + * no suspend states are valid. | |
130 | + * Valid states are advertised in /sys/power/state but can still | |
131 | + * be rejected by prepare or enter if the conditions aren't right. | |
132 | + * There is a %pm_valid_only_mem function available that can be assigned | |
133 | + * to this if you only implement mem sleep. | |
134 | 134 | * |
135 | 135 | * @prepare: Prepare the platform for the given suspend state. Can return a |
136 | 136 | * negative error code if necessary. |
kernel/power/main.c
... | ... | @@ -198,8 +198,8 @@ |
198 | 198 | |
199 | 199 | /* all other states need lowlevel support and need to be |
200 | 200 | * valid to the lowlevel implementation, no valid callback |
201 | - * implies that all are valid. */ | |
202 | - if (!pm_ops || (pm_ops->valid && !pm_ops->valid(state))) | |
201 | + * implies that none are valid. */ | |
202 | + if (!pm_ops || !pm_ops->valid || !pm_ops->valid(state)) | |
203 | 203 | return 0; |
204 | 204 | return 1; |
205 | 205 | } |