]> git.neil.brown.name Git - history.git/commitdiff
Consolidate ACPI and APM sysrq implementations.
authorPatrick Mochel <mochel@osdl.org>
Wed, 12 Feb 2003 13:06:37 +0000 (07:06 -0600)
committerPatrick Mochel <mochel@osdl.org>
Wed, 12 Feb 2003 13:06:37 +0000 (07:06 -0600)
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.

arch/i386/kernel/apm.c
drivers/acpi/sleep/main.c
kernel/pm.c

index 83524f1a0da50260b720e1d44f06f7a8a0e47540..d21b59a85ede8acb86536e26082d0ee625f8dc57 100644 (file)
 #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;
index 40038cbce760586dad185cc8e9ea8b07cfdacc91..9ce8041c7f6d53a983666ff795f3005ad2f1da46 100644 (file)
@@ -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
index fe5296045ec96ae7d4d8aaec46c19b4be988e1c6..f24f3df672f4c21b79287a80fa06bff4aac5476f 100644 (file)
@@ -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);