Commit 684750a2 authored by Patrick Mochel's avatar Patrick Mochel

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. 
parent 5c9829bb
......@@ -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;
......
......@@ -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
......
......@@ -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);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment