aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep/poweroff.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-07-30 18:14:15 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-07-30 18:14:15 -0400
commita670fcb43f01a67ef56176afc76e5d43d128b25c (patch)
tree09c9411c78a33ff980e9ea871bc7686e7589abbf /drivers/acpi/sleep/poweroff.c
parent327309e899662b482c58cf25f574513d38b5788c (diff)
parentb0825488a642cadcf39709961dde61440cb0731c (diff)
/spare/repo/netdev-2.6 branch 'master'
Diffstat (limited to 'drivers/acpi/sleep/poweroff.c')
-rw-r--r--drivers/acpi/sleep/poweroff.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index 1fc86e6b5ab9..186b182c5825 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -19,8 +19,6 @@
19 19
20int acpi_sleep_prepare(u32 acpi_state) 20int 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,28 +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
51void acpi_power_off(void) 47void 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 set_cpus_allowed(current, cpumask_of_cpu(0));
58 acpi_enter_sleep_state(ACPI_STATE_S5); 53 acpi_enter_sleep_state(ACPI_STATE_S5);
59} 54}
60 55
61#ifdef CONFIG_PM
62
63static int acpi_shutdown(struct sys_device *x) 56static int acpi_shutdown(struct sys_device *x)
64{ 57{
65 return acpi_sleep_prepare(ACPI_STATE_S5); 58 return acpi_sleep_prepare(ACPI_STATE_S5);
@@ -75,8 +68,6 @@ static struct sys_device device_acpi = {
75 .cls = &acpi_sysclass, 68 .cls = &acpi_sysclass,
76}; 69};
77 70
78#endif
79
80static int acpi_poweroff_init(void) 71static int acpi_poweroff_init(void)
81{ 72{
82 if (!acpi_disabled) { 73 if (!acpi_disabled) {
@@ -86,19 +77,18 @@ static int acpi_poweroff_init(void)
86 status = 77 status =
87 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);
88 if (ACPI_SUCCESS(status)) { 79 if (ACPI_SUCCESS(status)) {
89 pm_power_off = acpi_power_off; 80 int error;
90#ifdef CONFIG_PM 81 error = sysdev_class_register(&acpi_sysclass);
91 { 82 if (!error)
92 int error; 83 error = sysdev_register(&device_acpi);
93 error = sysdev_class_register(&acpi_sysclass); 84 if (!error)
94 if (!error) 85 pm_power_off = acpi_power_off;
95 error = sysdev_register(&device_acpi); 86 return error;
96 return error;
97 }
98#endif
99 } 87 }
100 } 88 }
101 return 0; 89 return 0;
102} 90}
103 91
104late_initcall(acpi_poweroff_init); 92late_initcall(acpi_poweroff_init);
93
94#endif /* CONFIG_PM */