public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI power-down in Linux 2.5.59
@ 2003-01-20 23:02 Tobias Ringstrom
       [not found] ` <Pine.LNX.4.44.0301202353530.21175-200000-CWfOIYxxj7kInT2dYjKYhA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Ringstrom @ 2003-01-20 23:02 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: TEXT/PLAIN, Size: 497 bytes --]

Dear ACPI experts,

I noticed that Linux 2.5.59 did not power-down when using ACPI. The reason 
is that you need CONFIG_ACPI_SLEEP which needs CONFIG_SOFTWARE_SUSPEND.  
Both are described as a bit dangerous in the config help.

As an experiment, I moved the power-down code from sleep.c to bus.c (which
seemed like a top-level file) and it seems to work well.  I've attached
the patch to this email.  Perhaps something like this can be considered
for future updates?  What do you think?

/Tobias

[-- Attachment #2: Type: TEXT/PLAIN, Size: 3305 bytes --]

diff -ru linux-2.5.59.orig/drivers/acpi/bus.c linux-2.5.59/drivers/acpi/bus.c
--- linux-2.5.59.orig/drivers/acpi/bus.c	2003-01-11 11:50:23.000000000 +0100
+++ linux-2.5.59/drivers/acpi/bus.c	2003-01-19 17:42:01.000000000 +0100
@@ -29,6 +29,7 @@
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/proc_fs.h>
+#include <linux/sysrq.h>
 #ifdef CONFIG_X86
 #include <asm/mpspec.h>
 #endif
@@ -676,11 +677,38 @@
 	return_VALUE(-ENODEV);
 }
 
+static void
+acpi_power_off (void)
+{
+	acpi_enter_sleep_state_prep(ACPI_STATE_S5);
+	ACPI_DISABLE_IRQS();
+	acpi_enter_sleep_state(ACPI_STATE_S5);
+}
+
+#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 */
+
 decl_subsys(acpi,NULL);
 
 static int __init acpi_init (void)
 {
 	int			result = 0;
+	acpi_status		status;
+	u8			type_a, type_b;
 
 	ACPI_FUNCTION_TRACE("acpi_init");
 
@@ -712,6 +740,13 @@
 	} else
 		acpi_disabled = 1;
 
+	/* Install the soft-off (S5) handler. */
+	status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
+	if (ACPI_SUCCESS(status)) {
+		pm_power_off = acpi_power_off;
+		register_sysrq_key('o', &sysrq_acpi_poweroff_op);
+	}
+
 	return_VALUE(result);
 }
 
diff -ru linux-2.5.59.orig/drivers/acpi/sleep.c linux-2.5.59/drivers/acpi/sleep.c
--- linux-2.5.59.orig/drivers/acpi/sleep.c	2003-01-06 23:26:51.000000000 +0100
+++ linux-2.5.59/drivers/acpi/sleep.c	2003-01-19 17:41:14.000000000 +0100
@@ -9,7 +9,6 @@
  */
 
 #include <linux/proc_fs.h>
-#include <linux/sysrq.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/pm.h>
@@ -53,14 +52,6 @@
 	.release	= single_release,
 };
 
-static void
-acpi_power_off (void)
-{
-	acpi_enter_sleep_state_prep(ACPI_STATE_S5);
-	ACPI_DISABLE_IRQS();
-	acpi_enter_sleep_state(ACPI_STATE_S5);
-}
-
 /**
  * acpi_system_restore_state - OS-specific restoration of state
  * @state:	sleep state we're exiting
@@ -625,24 +616,6 @@
 	return_VALUE(result ? result : count);
 }
 
-
-#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)
 {
 	struct proc_dir_entry	*entry = NULL;
@@ -690,11 +663,7 @@
 		entry->proc_fops->write = acpi_system_write_alarm;
 	}
 
-	/* 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
 		   indicate support. */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-21 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-20 23:02 [PATCH] ACPI power-down in Linux 2.5.59 Tobias Ringstrom
     [not found] ` <Pine.LNX.4.44.0301202353530.21175-200000-CWfOIYxxj7kInT2dYjKYhA@public.gmane.org>
2003-01-21 17:42   ` Pavel Machek

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