[linux-pm] What woke system up?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 20, 2005 at 06:11:40PM -0800, Patrick Mochel wrote:
> What about stashing a pointer to the device that did the wakeup, then
> using a symlink to point to the sysfs directory of that device? That way,
> instead of some arbitrary string, like "wake wake wake", you can
> definitively know what device it was, as well as any other status..
> 
> You can remove the symlink on suspend, just like you could clear the
> string, and re-add it on resume.

Sounds good, here's a new version that does just that.  Any further
improvements?  Thanks -- Todd

Add /sys/power/waker and pm_set_waker() for querying which device woke
the system.

Signed-off-by: Todd Poynor <tpoynor@xxxxxxxxxx>

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
@@ -15,6 +15,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/device.h>
 
 
 #include "power.h"
@@ -27,6 +28,8 @@ DECLARE_MUTEX(pm_sem);
 struct pm_ops *pm_ops;
 suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
 
+static void clear_waker(void);
+
 /**
  *	pm_set_ops - Set the global power method table. 
  *	@ops:	Pointer to ops structure.
@@ -108,6 +111,7 @@ static int suspend_enter(suspend_state_t
 	int error = 0;
 	unsigned long flags;
 
+	clear_waker();
 	local_irq_save(flags);
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
@@ -281,6 +285,16 @@ static ssize_t state_store(struct subsys
 
 power_attr(state);
 
+static void clear_waker(void)
+{
+	sysfs_remove_link(&power_subsys.kset.kobj, "waker");
+}
+
+void pm_set_waker(struct device *dev)
+{
+	sysfs_create_link(&power_subsys.kset.kobj, &dev->kobj, "waker");
+}
+
 static struct attribute * g[] = {
 	&state_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
@@ -131,6 +131,9 @@ extern void pm_set_ops(struct pm_ops *);
 extern struct pm_ops *pm_ops;
 extern int pm_suspend(suspend_state_t state);
 
+struct device;
+
+extern void pm_set_waker(struct device *dev);
 
 /*
  * Device power management


[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux