All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>, akpm <akpm@osdl.org>
Subject: [PATCH]introduce .valid callback in pm_ops
Date: Wed, 21 Sep 2005 09:08:06 +0800	[thread overview]
Message-ID: <1127264887.3927.3.camel@linux-hp.sh.intel.com> (raw)

Hi,
This patch adds .valid callback in pm_ops, so only available pm states
show in /sys/power/state. And this also makes an earlier states error
report at enter_state before we do actual suspend/resume.

Signed-off-by: Shaohua Li<shaohua.li@intel.com>
Acked-by: Pavel Machek<pavel@suse.cz> 

---

 linux-2.6.14-rc1-root/drivers/acpi/sleep/main.c |    8 ++++++++
 linux-2.6.14-rc1-root/include/linux/pm.h        |    1 +
 linux-2.6.14-rc1-root/kernel/power/main.c       |    5 ++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff -puN kernel/power/main.c~pm_states_cleanup kernel/power/main.c
--- linux-2.6.14-rc1/kernel/power/main.c~pm_states_cleanup	2005-09-19 16:32:53.000000000 +0800
+++ linux-2.6.14-rc1-root/kernel/power/main.c	2005-09-19 16:51:12.000000000 +0800
@@ -167,6 +167,8 @@ static int enter_state(suspend_state_t s
 {
 	int error;
 
+	if (pm_ops->valid && !pm_ops->valid(state))
+		return -ENODEV;
 	if (down_trylock(&pm_sem))
 		return -EBUSY;
 
@@ -236,7 +238,8 @@ static ssize_t state_show(struct subsyst
 	char * s = buf;
 
 	for (i = 0; i < PM_SUSPEND_MAX; i++) {
-		if (pm_states[i])
+		if (pm_states[i] && pm_ops && (!pm_ops->valid
+			||(pm_ops->valid && pm_ops->valid(i))))
 			s += sprintf(s,"%s ",pm_states[i]);
 	}
 	s += sprintf(s,"\n");
diff -puN include/linux/pm.h~pm_states_cleanup include/linux/pm.h
--- linux-2.6.14-rc1/include/linux/pm.h~pm_states_cleanup	2005-09-19 16:33:35.000000000 +0800
+++ linux-2.6.14-rc1-root/include/linux/pm.h	2005-09-19 16:50:38.000000000 +0800
@@ -170,6 +170,7 @@ typedef int __bitwise suspend_disk_metho
 
 struct pm_ops {
 	suspend_disk_method_t pm_disk_mode;
+	int (*valid)(suspend_state_t state);
 	int (*prepare)(suspend_state_t state);
 	int (*enter)(suspend_state_t state);
 	int (*finish)(suspend_state_t state);
diff -puN drivers/acpi/sleep/main.c~pm_states_cleanup drivers/acpi/sleep/main.c
--- linux-2.6.14-rc1/drivers/acpi/sleep/main.c~pm_states_cleanup	2005-09-19 16:42:26.000000000 +0800
+++ linux-2.6.14-rc1-root/drivers/acpi/sleep/main.c	2005-09-19 16:51:33.000000000 +0800
@@ -158,7 +158,15 @@ int acpi_suspend(u32 acpi_state)
 	return -EINVAL;
 }
 
+static int acpi_pm_state_valid(suspend_state_t pm_state)
+{
+	u32 acpi_state = acpi_suspend_states[pm_state];
+
+	return sleep_states[acpi_state];
+}
+
 static struct pm_ops acpi_pm_ops = {
+	.valid = acpi_pm_state_valid,
 	.prepare = acpi_pm_prepare,
 	.enter = acpi_pm_enter,
 	.finish = acpi_pm_finish,
_



                 reply	other threads:[~2005-09-21  1:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1127264887.3927.3.camel@linux-hp.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.