aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-07-06 22:09:38 -0400
committerLen Brown <len.brown@intel.com>2010-07-06 22:09:38 -0400
commit78f5f023167813130d2cf657d1b9eadc32f0e992 (patch)
tree8b15e1f2b05cb82e277b7d6bff94501608c225de
parent25bed55753b8cf243406e8837990b55946c5278d (diff)
ACPI / Wakeup: Simplify enabling of wakeup devices
To simplify the enabling of wakeup devices during system suspend and hibernation, merge acpi_enable_wakeup_device_prep() with acpi_disable_wakeup_device() and remove unnecessary (and no longer valid) comments from the latter. Rename acpi_enable_wakeup_device() to acpi_enable_wakeup_devices() and acpi_disable_wakeup_device() to acpi_disable_wakeup_devices(), because these functions usually operate on multiple device objects. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/sleep.c5
-rw-r--r--drivers/acpi/sleep.h5
-rw-r--r--drivers/acpi/wakeup.c48
3 files changed, 14 insertions, 44 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 8704ca78a8c4..93441c95c53b 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -73,8 +73,7 @@ static int acpi_sleep_prepare(u32 acpi_state)
73#endif 73#endif
74 printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n", 74 printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n",
75 acpi_state); 75 acpi_state);
76 acpi_enable_wakeup_device_prep(acpi_state); 76 acpi_enable_wakeup_devices(acpi_state);
77 acpi_enable_wakeup_device(acpi_state);
78 acpi_enter_sleep_state_prep(acpi_state); 77 acpi_enter_sleep_state_prep(acpi_state);
79 return 0; 78 return 0;
80} 79}
@@ -153,7 +152,7 @@ static void acpi_pm_finish(void)
153 152
154 printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n", 153 printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n",
155 acpi_state); 154 acpi_state);
156 acpi_disable_wakeup_device(acpi_state); 155 acpi_disable_wakeup_devices(acpi_state);
157 acpi_leave_sleep_state(acpi_state); 156 acpi_leave_sleep_state(acpi_state);
158 157
159 /* reset firmware waking vector */ 158 /* reset firmware waking vector */
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
index 25b8bd149284..d8821805c3bc 100644
--- a/drivers/acpi/sleep.h
+++ b/drivers/acpi/sleep.h
@@ -2,9 +2,8 @@
2extern u8 sleep_states[]; 2extern u8 sleep_states[];
3extern int acpi_suspend(u32 state); 3extern int acpi_suspend(u32 state);
4 4
5extern void acpi_enable_wakeup_device_prep(u8 sleep_state); 5extern void acpi_enable_wakeup_devices(u8 sleep_state);
6extern void acpi_enable_wakeup_device(u8 sleep_state); 6extern void acpi_disable_wakeup_devices(u8 sleep_state);
7extern void acpi_disable_wakeup_device(u8 sleep_state);
8 7
9extern struct list_head acpi_wakeup_device_list; 8extern struct list_head acpi_wakeup_device_list;
10extern struct mutex acpi_device_lock; 9extern struct mutex acpi_device_lock;
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 388747a7ef4f..dc6d1d9112fb 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -21,46 +21,18 @@
21ACPI_MODULE_NAME("wakeup_devices") 21ACPI_MODULE_NAME("wakeup_devices")
22 22
23/** 23/**
24 * acpi_enable_wakeup_device_prep - Prepare wake-up devices. 24 * acpi_enable_wakeup_devices - Enable wake-up device GPEs.
25 * @sleep_state: ACPI system sleep state. 25 * @sleep_state: ACPI system sleep state.
26 * 26 *
27 * Enable all wake-up devices' power, unless the requested system sleep state is 27 * Enable wakeup device power of devices with the state.enable flag set and set
28 * too deep. 28 * the wakeup enable mask bits in the GPE registers that correspond to wakeup
29 * devices.
29 */ 30 */
30void acpi_enable_wakeup_device_prep(u8 sleep_state) 31void acpi_enable_wakeup_devices(u8 sleep_state)
31{ 32{
32 struct list_head *node, *next; 33 struct list_head *node, *next;
33 34
34 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 35 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
35 struct acpi_device *dev = container_of(node,
36 struct acpi_device,
37 wakeup_list);
38
39 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
40 || (sleep_state > (u32) dev->wakeup.sleep_state))
41 continue;
42
43 acpi_enable_wakeup_device_power(dev, sleep_state);
44 }
45}
46
47/**
48 * acpi_enable_wakeup_device - Enable wake-up device GPEs.
49 * @sleep_state: ACPI system sleep state.
50 *
51 * Enable all wake-up devices' GPEs, with the assumption that
52 * acpi_disable_all_gpes() was executed before, so we don't need to disable any
53 * GPEs here.
54 */
55void acpi_enable_wakeup_device(u8 sleep_state)
56{
57 struct list_head *node, *next;
58
59 /*
60 * Caution: this routine must be invoked when interrupt is disabled
61 * Refer ACPI2.0: P212
62 */
63 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
64 struct acpi_device *dev = 36 struct acpi_device *dev =
65 container_of(node, struct acpi_device, wakeup_list); 37 container_of(node, struct acpi_device, wakeup_list);
66 38
@@ -68,6 +40,9 @@ void acpi_enable_wakeup_device(u8 sleep_state)
68 || sleep_state > (u32) dev->wakeup.sleep_state) 40 || sleep_state > (u32) dev->wakeup.sleep_state)
69 continue; 41 continue;
70 42
43 if (dev->wakeup.state.enabled)
44 acpi_enable_wakeup_device_power(dev, sleep_state);
45
71 /* The wake-up power should have been enabled already. */ 46 /* The wake-up power should have been enabled already. */
72 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 47 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
73 ACPI_GPE_TYPE_WAKE); 48 ACPI_GPE_TYPE_WAKE);
@@ -75,13 +50,10 @@ void acpi_enable_wakeup_device(u8 sleep_state)
75} 50}
76 51
77/** 52/**
78 * acpi_disable_wakeup_device - Disable devices' wakeup capability. 53 * acpi_disable_wakeup_devices - Disable devices' wakeup capability.
79 * @sleep_state: ACPI system sleep state. 54 * @sleep_state: ACPI system sleep state.
80 *
81 * This function only affects devices with wakeup.state.enabled set, which means
82 * that it reverses the changes made by acpi_enable_wakeup_device_prep().
83 */ 55 */
84void acpi_disable_wakeup_device(u8 sleep_state) 56void acpi_disable_wakeup_devices(u8 sleep_state)
85{ 57{
86 struct list_head *node, *next; 58 struct list_head *node, *next;
87 59