The syscore shutdown callback seems to be perfectly suited to prepare for system
poweroff. Use it instead of pm_power_off_prepare.

Cc: Rafael J. Wysocki <r...@rjwysocki.net>
Cc: Len Brown <len.br...@intel.com>
Signed-off-by: Guenter Roeck <li...@roeck-us.net>
---
 drivers/acpi/sleep.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 05a31b5..e03c74d 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/suspend.h>
 #include <linux/reboot.h>
+#include <linux/syscore_ops.h>
 #include <linux/acpi.h>
 #include <linux/module.h>
 #include <asm/io.h>
@@ -820,13 +821,23 @@ int acpi_suspend(u32 acpi_state)
        return -EINVAL;
 }
 
-static void acpi_power_off_prepare(void)
+static void acpi_shutdown(void)
 {
-       /* Prepare to power off the system */
-       acpi_sleep_prepare(ACPI_STATE_S5);
-       acpi_disable_all_gpes();
+       switch (system_state) {
+       case SYSTEM_POWER_OFF:
+               /* Prepare to power off the system */
+               acpi_sleep_prepare(ACPI_STATE_S5);
+               acpi_disable_all_gpes();
+               break;
+       default:
+               break;
+       }
 }
 
+static struct syscore_ops acpi_syscore_ops = {
+       .shutdown = acpi_shutdown,
+};
+
 static void acpi_power_off(void)
 {
        /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
@@ -850,7 +861,7 @@ int __init acpi_sleep_init(void)
 
        if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
                sleep_states[ACPI_STATE_S5] = 1;
-               pm_power_off_prepare = acpi_power_off_prepare;
+               register_syscore_ops(&acpi_syscore_ops);
                pm_power_off = acpi_power_off;
        }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to