Commit:     9684e51cd157607f0727c1550e7df6e31de40808
Parent:     e8c9c502690efd24b7055bf608e7a3c34216848b
Author:     Johannes Berg <[EMAIL PROTECTED]>
AuthorDate: Mon Apr 30 15:09:55 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Apr 30 16:40:40 2007 -0700

    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 <[EMAIL PROTECTED]>
    Acked-by: Pavel Machek <[EMAIL PROTECTED]>
    Looks-okay-to: Rafael J. Wysocki <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 include/linux/pm.h  |   12 ++++++------
 kernel/power/main.c |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 6035209..7a51669 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -125,12 +125,12 @@ typedef int __bitwise suspend_disk_method_t;
  * struct pm_ops - Callbacks for managing platform dependent suspend states.
  * @valid: Callback to determine whether the given state can be entered.
- *     always valid and never passed to this call.
- *     If not assigned, all suspend states are advertised as valid
- *     in /sys/power/state (but can still be rejected by prepare or enter.)
- *     Since new states can be added for other platforms, you should
- *     assign this callback. There is a %pm_valid_only_mem function
- *     available if you only implemented mem sleep.
+ *     always valid and never passed to this call. If not assigned,
+ *     no suspend states are valid.
+ *     Valid states are advertised in /sys/power/state but can still
+ *     be rejected by prepare or enter if the conditions aren't right.
+ *     There is a %pm_valid_only_mem function available that can be assigned
+ *     to this if you only implement mem sleep.
  * @prepare: Prepare the platform for the given suspend state. Can return a
  *     negative error code if necessary.
diff --git a/kernel/power/main.c b/kernel/power/main.c
index f94f4e2..72419a3 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -198,8 +198,8 @@ static inline int valid_state(suspend_state_t state)
        /* all other states need lowlevel support and need to be
         * valid to the lowlevel implementation, no valid callback
-        * implies that all are valid. */
-       if (!pm_ops || (pm_ops->valid && !pm_ops->valid(state)))
+        * implies that none are valid. */
+       if (!pm_ops || !pm_ops->valid || !pm_ops->valid(state))
                return 0;
        return 1;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to