public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* What woke system up?
@ 2005-12-21  0:29 Todd Poynor
  2005-12-21  2:11 ` Patrick Mochel
  2005-12-22 10:58 ` Pavel Machek
  0 siblings, 2 replies; 8+ messages in thread
From: Todd Poynor @ 2005-12-21  0:29 UTC (permalink / raw)
  To: linux-pm

[-- Attachment #1: Type: text/plain, Size: 2627 bytes --]

Next in our series of wakeup patches: a consumer electronics maker asked
for a userspace interface to inquire what woke the system up, in order
to present different behaviors depending on the wakeup source.  This is
to be encouraged, as it places these kinds of policy decisions into the
power policy application and out of the kernel.

So here's a quick try at adding a /sys/power/waker attribute and a
pm_add_waker() kernel function that either drivers or board PM code can
use to add (so far format-free) strings useful for telling what woke the
system up.  The idea is that a buffer of these strings is cleared at
each suspend and added to by the platform's resume path and/or driver
resume methods.

I'll send a patch or two for embedded boards showing how
this could be used for SoC-specific wakeup sources.

Any interest in this or something like it for Linux in general, or any
other suggestions?  Thanks -- Todd

Add /sys/power/waker and pm_add_waker() for board-specific wakeup info.

Index: linux-2.6.15-rc4/kernel/power/main.c
===================================================================
--- linux-2.6.15-rc4.orig/kernel/power/main.c
+++ linux-2.6.15-rc4/kernel/power/main.c
@@ -103,11 +103,18 @@ static int suspend_prepare(suspend_state
 }
 
 
+#define WAKERINFO_LEN 1024
+
+static char *wakerinfo;
+
 static int suspend_enter(suspend_state_t state)
 {
 	int error = 0;
 	unsigned long flags;
 
+	if (wakerinfo)
+		*wakerinfo = '\0';
+
 	local_irq_save(flags);
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
@@ -281,8 +288,35 @@ static ssize_t state_store(struct subsys
 
 power_attr(state);
 
+void pm_add_waker(char * buf)
+{
+	if (! wakerinfo) {
+		wakerinfo = kmalloc(WAKERINFO_LEN, GFP_KERNEL);
+
+		if (wakerinfo)
+			*wakerinfo = '\0';
+	}
+
+	if (wakerinfo)
+		strlcat(wakerinfo, buf, WAKERINFO_LEN);
+}
+
+static ssize_t waker_show(struct subsystem * subsys, char * buf)
+{
+	return sprintf(buf,"%s\n", wakerinfo ? wakerinfo : "");
+}
+
+static ssize_t waker_store(struct subsystem * subsys, const char * buf,
+			   size_t n)
+{
+	return -EINVAL;
+}
+
+power_attr(waker);
+
 static struct attribute * g[] = {
 	&state_attr.attr,
+	&waker_attr.attr,
 	NULL,
 };
 
Index: linux-2.6.15-rc4/include/linux/pm.h
===================================================================
--- linux-2.6.15-rc4.orig/include/linux/pm.h
+++ linux-2.6.15-rc4/include/linux/pm.h
@@ -130,7 +130,7 @@ struct pm_ops {
 extern void pm_set_ops(struct pm_ops *);
 extern struct pm_ops *pm_ops;
 extern int pm_suspend(suspend_state_t state);
-
+extern void pm_add_waker(char * buf);
 
 /*
  * Device power management


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-01-06  2:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-21  0:29 What woke system up? Todd Poynor
2005-12-21  2:11 ` Patrick Mochel
2005-12-22  3:46   ` Todd Poynor
2006-01-04 18:21     ` Leo L. Schwab
2006-01-05 15:08       ` Pavel Machek
2006-01-05 21:28       ` Patrick Mochel
2006-01-06  2:27         ` Todd Poynor
2005-12-22 10:58 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox