summaryrefslogtreecommitdiff
path: root/kernel/pm.c
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2003-02-12 07:06:37 -0600
committerPatrick Mochel <mochel@osdl.org>2003-02-12 07:06:37 -0600
commit684750a249d3a935ca09cec047a609b5fbdc3e04 (patch)
tree074fcc044a4c5d7c3f886c5309ebd1238e1c79b5 /kernel/pm.c
parent5c9829bbe66d7a131f9e49910aa2bd1d07eb170d (diff)
Consolidate ACPI and APM sysrq implementations.
Each power management scheme was implmenting a sysrq callback for 'o' which would call their respective power off routines. This moves the installation of the sysrq handler to kernel/pm.c, and calls pm_power_off(), which will work for any platform that has that method defined.
Diffstat (limited to 'kernel/pm.c')
-rw-r--r--kernel/pm.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/kernel/pm.c b/kernel/pm.c
index fe5296045ec9..f24f3df672f4 100644
--- a/kernel/pm.c
+++ b/kernel/pm.c
@@ -24,6 +24,7 @@
#include <linux/slab.h>
#include <linux/pm.h>
#include <linux/interrupt.h>
+#include <linux/sysrq.h>
int pm_active;
@@ -292,3 +293,41 @@ EXPORT_SYMBOL(pm_send);
EXPORT_SYMBOL(pm_send_all);
EXPORT_SYMBOL(pm_find);
EXPORT_SYMBOL(pm_active);
+
+
+#ifdef CONFIG_MAGIC_SYSRQ
+
+/**
+ * handle_poweroff - sysrq callback for power down
+ * @key: key pressed (unused)
+ * @pt_regs: register state (unused)
+ * @kbd: keyboard state (unused)
+ * @tty: tty involved (unused)
+ *
+ * When the user hits Sys-Rq o to power down the machine this is the
+ * callback we use.
+ */
+
+static void handle_poweroff (int key, struct pt_regs *pt_regs,
+ struct tty_struct *tty)
+{
+ if (pm_power_off)
+ pm_power_off();
+}
+
+static struct sysrq_key_op sysrq_poweroff_op = {
+ .handler = handle_poweroff,
+ .help_msg = "powerOff",
+ .action_msg = "Power Off\n"
+};
+
+#endif /* CONFIG_MAGIC_SYSRQ */
+
+
+static int pm_init(void)
+{
+ register_sysrq_key('o', &sysrq_poweroff_op);
+ return 0;
+}
+
+subsys_initcall(pm_init);