summaryrefslogtreecommitdiff
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
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.
-rw-r--r--arch/i386/kernel/apm.c28
-rw-r--r--drivers/acpi/sleep/main.c20
-rw-r--r--kernel/pm.c39
3 files changed, 39 insertions, 48 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 83524f1a0da5..d21b59a85ede 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -226,8 +226,6 @@
#include <asm/uaccess.h>
#include <asm/desc.h>
-#include <linux/sysrq.h>
-
extern spinlock_t i8253_lock;
extern unsigned long get_cmos_time(void);
extern void machine_real_restart(unsigned char *, int);
@@ -972,30 +970,6 @@ static void apm_power_off(void)
(void) set_system_power_state(APM_STATE_OFF);
}
-/**
- * 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)
-{
- apm_power_off();
-}
-
-static struct sysrq_key_op sysrq_poweroff_op = {
- .handler = handle_poweroff,
- .help_msg = "Off",
- .action_msg = "Power Off\n"
-};
-
-
#ifdef CONFIG_APM_DO_ENABLE
/**
@@ -1848,7 +1822,6 @@ static int apm(void *unused)
/* Install our power off handler.. */
if (power_off)
pm_power_off = apm_power_off;
- register_sysrq_key('o', &sysrq_poweroff_op);
if (num_online_cpus() == 1 || smp) {
#if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
@@ -2096,7 +2069,6 @@ static void __exit apm_exit(void)
}
misc_deregister(&apm_device);
remove_proc_entry("apm", NULL);
- unregister_sysrq_key('o',&sysrq_poweroff_op);
if (power_off)
pm_power_off = NULL;
exit_kapmd = 1;
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 40038cbce760..9ce8041c7f6d 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -8,8 +8,6 @@
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
*/
-#include <linux/kernel.h>
-#include <linux/sysrq.h>
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/pm.h>
@@ -265,23 +263,6 @@ acpi_suspend (
return status;
}
-#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_PM)
-
-/* Simple wrapper calling power down function. */
-static void acpi_sysrq_power_off(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
-{
- acpi_power_off();
-}
-
-struct sysrq_key_op sysrq_acpi_poweroff_op = {
- .handler = &acpi_sysrq_power_off,
- .help_msg = "Off",
- .action_msg = "Power Off\n"
-};
-
-#endif /* CONFIG_MAGIC_SYSRQ */
-
static int __init acpi_sleep_init(void)
{
acpi_status status = AE_OK;
@@ -308,7 +289,6 @@ static int __init acpi_sleep_init(void)
/* Install the soft-off (S5) handler. */
if (sleep_states[ACPI_STATE_S5]) {
pm_power_off = acpi_power_off;
- register_sysrq_key('o', &sysrq_acpi_poweroff_op);
/* workaround: some systems don't claim S4 support, but they
do support S5 (power-down). That is all we need, so
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);