[patch] ACPI power off via sysrq

Wolly (wwolly@gmx.net)
Mon, 11 Mar 2002 14:30:30 +0100


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
> 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>---------------------------
diff -u sm_osl.c sm_osl.c-patched
--- sm_osl.c Mon Mar 11 12:52:07 2002
+++ sm_osl.c-patched Mon Mar 11 14:01:28 2002
@@ -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);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/