ACPI power off via sysrq
PATCH 1/1 ACPI power off via sysrq
I notized that APM is able to power off the machine using sysrq key `o´ while ACPI is not. So, here is a patch to fix that.
I've tested this patch with and without sysrq config and it works fine for me.
Andy [Grover], please check if things are okay. I inserted a
Quoted 1 line
pm_power_off=sm_pm_power_off;
in the cleanup routine as it appears to me that the setup routine saves the original power off function in sm_pm_power_off and it would probably be wise to restore the original pointer upon cleanup...
Regards,
Wolly
Patch is against 2.4.18 kernel;
patched file sm_osl.c is in drivers/acpi/ospm/system/
---------------------------<patch>---------------------------
sm_osl.c-patched renamed from sm_osl.c +26 -0
@@ -36,6 +36,8 @@ #include <linux/mc146818rtc.h> #include <linux/delay.h> +#include <linux/sysrq.h> + #include <acpi.h> #include "sm.h"
@@ -737,6 +739,24 @@ } +#ifdef CONFIG_MAGIC_SYSRQ + +/* Simple wrapper calling power down function. */ +static void sysrq_sm_osl_power_down(int key, struct pt_regs *pt_regs, + struct kbd_struct *kbd, struct tty_struct *tty) +{ + sm_osl_power_down(); +} + +struct sysrq_key_op sysrq_acpi_poweroff_op = { + handler: &sm_osl_power_down, + help_msg: "Off", + action_msg: "Power Off\n" +}; + +#endif /* CONFIG_MAGIC_SYSRQ */ + + /**************************************************************************** * * FUNCTION: sm_osl_add_device
@@ -765,6 +785,7 @@ if (system->states[ACPI_STATE_S5]) { sm_pm_power_off = pm_power_off; pm_power_off = sm_osl_power_down; + register_sysrq_key('o', &sysrq_acpi_poweroff_op); } create_proc_read_entry(SM_PROC_INFO, S_IRUGO,
@@ -828,6 +849,11 @@ remove_proc_entry(SM_PROC_INFO, sm_proc_root); remove_proc_entry(SM_PROC_DSDT, sm_proc_root); + + unregister_sysrq_key('o', &sysrq_acpi_poweroff_op); + + /* Restore power off vector... */ + pm_power_off = sm_pm_power_off; return(AE_OK); }