diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2005-07-26 14:17:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-26 17:35:45 -0400 |
commit | b35c67a46b025e8dc320b59fbe5c283094e1d7f5 (patch) | |
tree | dd22c5d664496ce9caab45825bb7f7ab1fe60545 /drivers/acpi | |
parent | 6660316cb7a1a2c59a73a52870490c0f782f45c1 (diff) |
[PATCH] acpi: Don't call acpi_sleep_prepare from acpi_power_off
Now that all of the code paths that call acpi_power_off
have been modified to call either call kernel_power_off
(which calls apci_sleep_prepare by way of acpi_shutdown)
or to call acpi_sleep_prepare directly it is redundant to call
acpi_sleep_prepare from acpi_power_off.
So simplify the code and simply don't call acpi_sleep_prepare.
In addition there is a little error handling done so if we
can't register the acpi class we don't hook pm_power_off.
I think I have done the right thing with the CONFIG_PM define
but I'm not certain. Can this code even be compiled if
CONFIG_PM is false?
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/sleep/poweroff.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index 3d41d93a3db8..186b182c5825 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c | |||
@@ -19,8 +19,6 @@ | |||
19 | 19 | ||
20 | int acpi_sleep_prepare(u32 acpi_state) | 20 | int acpi_sleep_prepare(u32 acpi_state) |
21 | { | 21 | { |
22 | /* Flag to do not allow second time invocation for S5 state */ | ||
23 | static int shutdown_prepared = 0; | ||
24 | #ifdef CONFIG_ACPI_SLEEP | 22 | #ifdef CONFIG_ACPI_SLEEP |
25 | /* do we have a wakeup address for S2 and S3? */ | 23 | /* do we have a wakeup address for S2 and S3? */ |
26 | /* Here, we support only S4BIOS, those we set the wakeup address */ | 24 | /* Here, we support only S4BIOS, those we set the wakeup address */ |
@@ -38,27 +36,23 @@ int acpi_sleep_prepare(u32 acpi_state) | |||
38 | acpi_enable_wakeup_device_prep(acpi_state); | 36 | acpi_enable_wakeup_device_prep(acpi_state); |
39 | #endif | 37 | #endif |
40 | if (acpi_state == ACPI_STATE_S5) { | 38 | if (acpi_state == ACPI_STATE_S5) { |
41 | /* Check if we were already called */ | ||
42 | if (shutdown_prepared) | ||
43 | return 0; | ||
44 | acpi_wakeup_gpe_poweroff_prepare(); | 39 | acpi_wakeup_gpe_poweroff_prepare(); |
45 | shutdown_prepared = 1; | ||
46 | } | 40 | } |
47 | acpi_enter_sleep_state_prep(acpi_state); | 41 | acpi_enter_sleep_state_prep(acpi_state); |
48 | return 0; | 42 | return 0; |
49 | } | 43 | } |
50 | 44 | ||
45 | #ifdef CONFIG_PM | ||
46 | |||
51 | void acpi_power_off(void) | 47 | void acpi_power_off(void) |
52 | { | 48 | { |
49 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ | ||
53 | printk("%s called\n", __FUNCTION__); | 50 | printk("%s called\n", __FUNCTION__); |
54 | acpi_sleep_prepare(ACPI_STATE_S5); | ||
55 | local_irq_disable(); | 51 | local_irq_disable(); |
56 | /* Some SMP machines only can poweroff in boot CPU */ | 52 | /* Some SMP machines only can poweroff in boot CPU */ |
57 | acpi_enter_sleep_state(ACPI_STATE_S5); | 53 | acpi_enter_sleep_state(ACPI_STATE_S5); |
58 | } | 54 | } |
59 | 55 | ||
60 | #ifdef CONFIG_PM | ||
61 | |||
62 | static int acpi_shutdown(struct sys_device *x) | 56 | static int acpi_shutdown(struct sys_device *x) |
63 | { | 57 | { |
64 | return acpi_sleep_prepare(ACPI_STATE_S5); | 58 | return acpi_sleep_prepare(ACPI_STATE_S5); |
@@ -74,8 +68,6 @@ static struct sys_device device_acpi = { | |||
74 | .cls = &acpi_sysclass, | 68 | .cls = &acpi_sysclass, |
75 | }; | 69 | }; |
76 | 70 | ||
77 | #endif | ||
78 | |||
79 | static int acpi_poweroff_init(void) | 71 | static int acpi_poweroff_init(void) |
80 | { | 72 | { |
81 | if (!acpi_disabled) { | 73 | if (!acpi_disabled) { |
@@ -85,19 +77,18 @@ static int acpi_poweroff_init(void) | |||
85 | status = | 77 | status = |
86 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); | 78 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
87 | if (ACPI_SUCCESS(status)) { | 79 | if (ACPI_SUCCESS(status)) { |
88 | pm_power_off = acpi_power_off; | 80 | int error; |
89 | #ifdef CONFIG_PM | 81 | error = sysdev_class_register(&acpi_sysclass); |
90 | { | 82 | if (!error) |
91 | int error; | 83 | error = sysdev_register(&device_acpi); |
92 | error = sysdev_class_register(&acpi_sysclass); | 84 | if (!error) |
93 | if (!error) | 85 | pm_power_off = acpi_power_off; |
94 | error = sysdev_register(&device_acpi); | 86 | return error; |
95 | return error; | ||
96 | } | ||
97 | #endif | ||
98 | } | 87 | } |
99 | } | 88 | } |
100 | return 0; | 89 | return 0; |
101 | } | 90 | } |
102 | 91 | ||
103 | late_initcall(acpi_poweroff_init); | 92 | late_initcall(acpi_poweroff_init); |
93 | |||
94 | #endif /* CONFIG_PM */ | ||