diff options
-rw-r--r-- | drivers/acpi/sleep/poweroff.c | 38 | ||||
-rw-r--r-- | include/linux/pm.h | 1 | ||||
-rw-r--r-- | kernel/sys.c | 9 |
3 files changed, 19 insertions, 29 deletions
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index 240dde9cf13a..39e40d56b034 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c | |||
@@ -39,7 +39,13 @@ int acpi_sleep_prepare(u32 acpi_state) | |||
39 | 39 | ||
40 | #ifdef CONFIG_PM | 40 | #ifdef CONFIG_PM |
41 | 41 | ||
42 | void acpi_power_off(void) | 42 | static void acpi_power_off_prepare(void) |
43 | { | ||
44 | /* Prepare to power off the system */ | ||
45 | acpi_sleep_prepare(ACPI_STATE_S5); | ||
46 | } | ||
47 | |||
48 | static void acpi_power_off(void) | ||
43 | { | 49 | { |
44 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ | 50 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ |
45 | printk("%s called\n", __FUNCTION__); | 51 | printk("%s called\n", __FUNCTION__); |
@@ -48,27 +54,6 @@ void acpi_power_off(void) | |||
48 | acpi_enter_sleep_state(ACPI_STATE_S5); | 54 | acpi_enter_sleep_state(ACPI_STATE_S5); |
49 | } | 55 | } |
50 | 56 | ||
51 | static int acpi_shutdown(struct sys_device *x) | ||
52 | { | ||
53 | switch (system_state) { | ||
54 | case SYSTEM_POWER_OFF: | ||
55 | /* Prepare to power off the system */ | ||
56 | return acpi_sleep_prepare(ACPI_STATE_S5); | ||
57 | default: | ||
58 | return 0; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | static struct sysdev_class acpi_sysclass = { | ||
63 | set_kset_name("acpi"), | ||
64 | .shutdown = acpi_shutdown | ||
65 | }; | ||
66 | |||
67 | static struct sys_device device_acpi = { | ||
68 | .id = 0, | ||
69 | .cls = &acpi_sysclass, | ||
70 | }; | ||
71 | |||
72 | static int acpi_poweroff_init(void) | 57 | static int acpi_poweroff_init(void) |
73 | { | 58 | { |
74 | if (!acpi_disabled) { | 59 | if (!acpi_disabled) { |
@@ -78,13 +63,8 @@ static int acpi_poweroff_init(void) | |||
78 | status = | 63 | status = |
79 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); | 64 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
80 | if (ACPI_SUCCESS(status)) { | 65 | if (ACPI_SUCCESS(status)) { |
81 | int error; | 66 | pm_power_off_prepare = acpi_power_off_prepare; |
82 | error = sysdev_class_register(&acpi_sysclass); | 67 | pm_power_off = acpi_power_off; |
83 | if (!error) | ||
84 | error = sysdev_register(&device_acpi); | ||
85 | if (!error) | ||
86 | pm_power_off = acpi_power_off; | ||
87 | return error; | ||
88 | } | 68 | } |
89 | } | 69 | } |
90 | return 0; | 70 | return 0; |
diff --git a/include/linux/pm.h b/include/linux/pm.h index 2735b7cadd20..ad3cc2eb0d34 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -101,6 +101,7 @@ struct pm_dev | |||
101 | */ | 101 | */ |
102 | extern void (*pm_idle)(void); | 102 | extern void (*pm_idle)(void); |
103 | extern void (*pm_power_off)(void); | 103 | extern void (*pm_power_off)(void); |
104 | extern void (*pm_power_off_prepare)(void); | ||
104 | 105 | ||
105 | typedef int __bitwise suspend_state_t; | 106 | typedef int __bitwise suspend_state_t; |
106 | 107 | ||
diff --git a/kernel/sys.c b/kernel/sys.c index 18987c7f6add..d40e40a9446c 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -100,6 +100,13 @@ struct pid *cad_pid; | |||
100 | EXPORT_SYMBOL(cad_pid); | 100 | EXPORT_SYMBOL(cad_pid); |
101 | 101 | ||
102 | /* | 102 | /* |
103 | * If set, this is used for preparing the system to power off. | ||
104 | */ | ||
105 | |||
106 | void (*pm_power_off_prepare)(void); | ||
107 | EXPORT_SYMBOL(pm_power_off_prepare); | ||
108 | |||
109 | /* | ||
103 | * Notifier list for kernel code which wants to be called | 110 | * Notifier list for kernel code which wants to be called |
104 | * at shutdown. This is used to stop any idling DMA operations | 111 | * at shutdown. This is used to stop any idling DMA operations |
105 | * and the like. | 112 | * and the like. |
@@ -867,6 +874,8 @@ EXPORT_SYMBOL_GPL(kernel_halt); | |||
867 | void kernel_power_off(void) | 874 | void kernel_power_off(void) |
868 | { | 875 | { |
869 | kernel_shutdown_prepare(SYSTEM_POWER_OFF); | 876 | kernel_shutdown_prepare(SYSTEM_POWER_OFF); |
877 | if (pm_power_off_prepare) | ||
878 | pm_power_off_prepare(); | ||
870 | printk(KERN_EMERG "Power down.\n"); | 879 | printk(KERN_EMERG "Power down.\n"); |
871 | machine_power_off(); | 880 | machine_power_off(); |
872 | } | 881 | } |