mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] ACPI power off via sysrq
@ 2002-03-11 13:30 Wolly
  0 siblings, 0 replies; only message in thread
From: Wolly @ 2002-03-11 13:30 UTC (permalink / raw)
  To: andrew.grover, acpi-devel; +Cc: linux-kernel

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);
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-03-11 13:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-11 13:30 [patch] ACPI power off via sysrq Wolly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®