]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ACPI / Wakeup: Simplify enabling of wakeup devices
authorRafael J. Wysocki <rjw@sisk.pl>
Wed, 7 Jul 2010 02:09:38 +0000 (22:09 -0400)
committerLen Brown <len.brown@intel.com>
Wed, 7 Jul 2010 02:09:38 +0000 (22:09 -0400)
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>
drivers/acpi/sleep.c
drivers/acpi/sleep.h
drivers/acpi/wakeup.c

index 8704ca78a8c4ea287b9ed5facd2ca26c747683a4..93441c95c53b8d9053bcd25e9cb9f35ab0660ade 100644 (file)
@@ -73,8 +73,7 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #endif
        printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n",
                acpi_state);
-       acpi_enable_wakeup_device_prep(acpi_state);
-       acpi_enable_wakeup_device(acpi_state);
+       acpi_enable_wakeup_devices(acpi_state);
        acpi_enter_sleep_state_prep(acpi_state);
        return 0;
 }
@@ -153,7 +152,7 @@ static void acpi_pm_finish(void)
 
        printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n",
                acpi_state);
-       acpi_disable_wakeup_device(acpi_state);
+       acpi_disable_wakeup_devices(acpi_state);
        acpi_leave_sleep_state(acpi_state);
 
        /* reset firmware waking vector */
index 25b8bd149284fb7f13de1018bf66c806dd855f9e..d8821805c3bc9ab4637732d5d7ee6f105620b83f 100644 (file)
@@ -2,9 +2,8 @@
 extern u8 sleep_states[];
 extern int acpi_suspend(u32 state);
 
-extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
-extern void acpi_enable_wakeup_device(u8 sleep_state);
-extern void acpi_disable_wakeup_device(u8 sleep_state);
+extern void acpi_enable_wakeup_devices(u8 sleep_state);
+extern void acpi_disable_wakeup_devices(u8 sleep_state);
 
 extern struct list_head acpi_wakeup_device_list;
 extern struct mutex acpi_device_lock;
index 388747a7ef4fc261b4e09db7866bc86bb9b17570..dc6d1d9112fb58809a6db021a6eba031d7d2315b 100644 (file)
 ACPI_MODULE_NAME("wakeup_devices")
 
 /**
- * acpi_enable_wakeup_device_prep - Prepare wake-up devices.
+ * acpi_enable_wakeup_devices - Enable wake-up device GPEs.
  * @sleep_state: ACPI system sleep state.
  *
- * Enable all wake-up devices' power, unless the requested system sleep state is
- * too deep.
+ * Enable wakeup device power of devices with the state.enable flag set and set
+ * the wakeup enable mask bits in the GPE registers that correspond to wakeup
+ * devices.
  */
-void acpi_enable_wakeup_device_prep(u8 sleep_state)
+void acpi_enable_wakeup_devices(u8 sleep_state)
 {
        struct list_head *node, *next;
 
-       list_for_each_safe(node, next, &acpi_wakeup_device_list) {
-               struct acpi_device *dev = container_of(node,
-                                                      struct acpi_device,
-                                                      wakeup_list);
-
-               if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
-                   || (sleep_state > (u32) dev->wakeup.sleep_state))
-                       continue;
-
-               acpi_enable_wakeup_device_power(dev, sleep_state);
-       }
-}
-
-/**
- * acpi_enable_wakeup_device - Enable wake-up device GPEs.
- * @sleep_state: ACPI system sleep state.
- *
- * Enable all wake-up devices' GPEs, with the assumption that
- * acpi_disable_all_gpes() was executed before, so we don't need to disable any
- * GPEs here.
- */
-void acpi_enable_wakeup_device(u8 sleep_state)
-{
-       struct list_head *node, *next;
-
-       /* 
-        * Caution: this routine must be invoked when interrupt is disabled 
-        * Refer ACPI2.0: P212
-        */
        list_for_each_safe(node, next, &acpi_wakeup_device_list) {
                struct acpi_device *dev =
                        container_of(node, struct acpi_device, wakeup_list);
@@ -68,6 +40,9 @@ void acpi_enable_wakeup_device(u8 sleep_state)
                    || sleep_state > (u32) dev->wakeup.sleep_state)
                        continue;
 
+               if (dev->wakeup.state.enabled)
+                       acpi_enable_wakeup_device_power(dev, sleep_state);
+
                /* The wake-up power should have been enabled already. */
                acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
                                ACPI_GPE_TYPE_WAKE);
@@ -75,13 +50,10 @@ void acpi_enable_wakeup_device(u8 sleep_state)
 }
 
 /**
- * acpi_disable_wakeup_device - Disable devices' wakeup capability.
+ * acpi_disable_wakeup_devices - Disable devices' wakeup capability.
  * @sleep_state: ACPI system sleep state.
- *
- * This function only affects devices with wakeup.state.enabled set, which means
- * that it reverses the changes made by acpi_enable_wakeup_device_prep().
  */
-void acpi_disable_wakeup_device(u8 sleep_state)
+void acpi_disable_wakeup_devices(u8 sleep_state)
 {
        struct list_head *node, *next;