]> git.hungrycats.org Git - linux/commitdiff
acpi sleep: divorce sleep functionality from power off functionality.
authorPatrick Mochel <mochel@osdl.org>
Wed, 12 Feb 2003 13:35:58 +0000 (07:35 -0600)
committerPatrick Mochel <mochel@osdl.org>
Wed, 12 Feb 2003 13:35:58 +0000 (07:35 -0600)
When ACPI turns the system off on shutdown, it actually enters S5, a sleep
state. This functionality is dependent on CONFIG_ACPI_SLEEP, which is
dependent on CONFIG_SOFTWARE_SUSPEND.

This patch breaks the power off functionality into a separate file, and
removes the dependency on the above-mentioned crap. Finally, power off works
for me again.

Thanks to Tobias Ringstrom for the original patch.

drivers/acpi/Makefile
drivers/acpi/sleep/Makefile
drivers/acpi/sleep/main.c
drivers/acpi/sleep/poweroff.c [new file with mode: 0644]

index 0203f8fee6db8469b53383c90b3e92ddd5367159..ee03719995e2a60fe0ca891e90454c6215e3c97a 100644 (file)
@@ -30,6 +30,7 @@ obj-$(CONFIG_ACPI_INTERPRETER)        += osl.o utils.o \
 #
 # ACPI Bus and Device Drivers
 #
+obj-y                          += sleep/
 obj-$(CONFIG_ACPI_BUS)         += bus.o
 obj-$(CONFIG_ACPI_AC)          += ac.o
 obj-$(CONFIG_ACPI_BATTERY)     += battery.o
@@ -42,7 +43,6 @@ obj-$(CONFIG_ACPI_PROCESSOR)  += processor.o
 obj-$(CONFIG_ACPI_THERMAL)     += thermal.o
 obj-$(CONFIG_ACPI_SYSTEM)      += system.o event.o
 obj-$(CONFIG_ACPI_DEBUG)       += debug.o
-obj-$(CONFIG_ACPI_SLEEP)       += sleep/
 obj-$(CONFIG_ACPI_NUMA)                += numa.o
 obj-$(CONFIG_ACPI_TOSHIBA)     += toshiba_acpi.o
 obj-$(CONFIG_ACPI_BUS)         += scan.o 
index 53a63cce0b2d84578d6a4c0b7a88ac59f289d7bb..7da166e9603203503dca186181997328b613a941 100644 (file)
@@ -1,4 +1,5 @@
-obj-y                  := main.o 
-obj-$(CONFIG_PROC_FS)  += proc.o
+obj-y                          := poweroff.o
+obj-$(CONFIG_ACPI_SLEEP)       += main.o
+obj-$(CONFIG_PROC_FS)          += proc.o
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
index 9ce8041c7f6d53a983666ff795f3005ad2f1da46..fb1bd6848c39bff46c92f568a76c6a064326b557 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * sleep.c - ACPI sleep support.
  * 
- *  Copyright (c) 2000-2002 Patrick Mochel
+ *  Copyright (c) 2000-2003 Patrick Mochel
  *
  *  Portions are
  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
 
 #include <linux/delay.h>
 #include <linux/irq.h>
-#include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/suspend.h>
-
-#include <asm/acpi.h>
-
 #include <acpi/acpi_bus.h>
-#include <acpi/acpi_drivers.h>
-
 #include "sleep.h"
 
 #define _COMPONENT             ACPI_SYSTEM_COMPONENT
@@ -26,14 +20,6 @@ ACPI_MODULE_NAME             ("sleep")
 
 u8 sleep_states[ACPI_S_STATE_COUNT];
 
-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
@@ -265,7 +251,6 @@ acpi_suspend (
 
 static int __init acpi_sleep_init(void)
 {
-       acpi_status             status = AE_OK;
        int                     i = 0;
 
        ACPI_FUNCTION_TRACE("acpi_system_add_fs");
@@ -275,6 +260,7 @@ static int __init acpi_sleep_init(void)
 
        printk(KERN_INFO PREFIX "(supports");
        for (i=0; i<ACPI_S_STATE_COUNT; i++) {
+               acpi_status status;
                u8 type_a, type_b;
                status = acpi_get_sleep_type_data(i, &type_a, &type_b);
                if (ACPI_SUCCESS(status)) {
@@ -286,16 +272,6 @@ static int __init acpi_sleep_init(void)
 
        acpi_sleep_proc_init();
 
-       /* Install the soft-off (S5) handler. */
-       if (sleep_states[ACPI_STATE_S5]) {
-               pm_power_off = acpi_power_off;
-
-               /* workaround: some systems don't claim S4 support, but they
-                   do support S5 (power-down). That is all we need, so
-                  indicate support. */
-               sleep_states[ACPI_STATE_S4] = 1;
-       }
-
        return_VALUE(0);
 }
 
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
new file mode 100644 (file)
index 0000000..0eb181e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * poweroff.c - ACPI handler for powering off the system.
+ *
+ * AKA S5, but it is independent of whether or not the kernel supports
+ * any other sleep support in the system.
+ */
+
+#include <linux/pm.h>
+#include <linux/init.h>
+#include <acpi/acpi_bus.h>
+
+static void
+acpi_power_off (void)
+{
+       printk("%s called\n",__FUNCTION__);
+       acpi_enter_sleep_state_prep(ACPI_STATE_S5);
+       ACPI_DISABLE_IRQS();
+       acpi_enter_sleep_state(ACPI_STATE_S5);
+}
+
+static int acpi_poweroff_init(void)
+{
+       if (!acpi_disabled) {
+               u8 type_a, type_b;
+               acpi_status status;
+
+               status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
+               if (ACPI_SUCCESS(status))
+                       pm_power_off = acpi_power_off;
+       }
+       return 0;
+}
+
+late_initcall(acpi_poweroff_init);