public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-pm <linux-pm@lists.linux-foundation.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: [PATCH] power management: force pm_ops.valid callback to be	assigned
Date: Thu, 22 Mar 2007 14:44:02 +0100	[thread overview]
Message-ID: <1174571042.32051.2.camel@johannes.berg> (raw)

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>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org

---
 include/linux/pm.h  |   12 ++++++------
 kernel/power/main.c |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

--- linux-2.6.orig/include/linux/pm.h	2007-03-22 14:35:14.764654656 +0100
+++ linux-2.6/include/linux/pm.h	2007-03-22 14:36:38.784654656 +0100
@@ -125,12 +125,12 @@ typedef int __bitwise suspend_disk_metho
  * struct pm_ops - Callbacks for managing platform dependent suspend states.
  * @valid: Callback to determine whether the given state can be entered.
  * 	If %CONFIG_SOFTWARE_SUSPEND is set then %PM_SUSPEND_DISK is
- *	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.
--- linux-2.6.orig/kernel/power/main.c	2007-03-22 14:36:46.044654656 +0100
+++ linux-2.6/kernel/power/main.c	2007-03-22 14:40:29.664654656 +0100
@@ -186,8 +186,8 @@ static inline int valid_state(suspend_st
 
 	/* 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;
 }

             reply	other threads:[~2007-03-22 13:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-22 13:44 Johannes Berg [this message]
2007-03-22 21:15 ` [PATCH] power management: force pm_ops.valid callback to be assigned Rafael J. Wysocki
2007-03-25 16:30 ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1174571042.32051.2.camel@johannes.berg \
    --to=johannes@sipsolutions.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox