diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-07-19 04:47:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:42 -0400 |
commit | bd804eba1c8597cbb7cd5a5f9fe886aae16a079a (patch) | |
tree | 082f289809f92db6d23a13cd8fbbb82da125fcda /drivers/acpi/sleep/poweroff.c | |
parent | d7372cdf6938ccea23ec9fc68970702fed9ec3c8 (diff) |
PM: Introduce pm_power_off_prepare
Introduce the pm_power_off_prepare() callback that can be registered by the
interested platforms in analogy with pm_idle() and pm_power_off(), used for
preparing the system to power off (needed by ACPI).
This allows us to drop acpi_sysclass and device_acpi that are only defined in
order to register the ACPI power off preparation callback, which is needed by
pm_power_off() registered in a much different way.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/acpi/sleep/poweroff.c')
-rw-r--r-- | drivers/acpi/sleep/poweroff.c | 38 |
1 files changed, 9 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; |