ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / acpi / sleep / poweroff.c
1 /*
2  * poweroff.c - ACPI handler for powering off the system.
3  *
4  * AKA S5, but it is independent of whether or not the kernel supports
5  * any other sleep support in the system.
6  */
7
8 #include <linux/pm.h>
9 #include <linux/init.h>
10 #include <acpi/acpi_bus.h>
11 #include <linux/sched.h>
12
13 static void
14 acpi_power_off (void)
15 {
16         printk("%s called\n",__FUNCTION__);
17         /* Some SMP machines only can poweroff in boot CPU */
18         set_cpus_allowed(current, cpumask_of_cpu(0));
19         acpi_enter_sleep_state_prep(ACPI_STATE_S5);
20         ACPI_DISABLE_IRQS();
21         acpi_enter_sleep_state(ACPI_STATE_S5);
22 }
23
24 static int acpi_poweroff_init(void)
25 {
26         if (!acpi_disabled) {
27                 u8 type_a, type_b;
28                 acpi_status status;
29
30                 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
31                 if (ACPI_SUCCESS(status))
32                         pm_power_off = acpi_power_off;
33         }
34         return 0;
35 }
36
37 late_initcall(acpi_poweroff_init);