]> git.hungrycats.org Git - linux/commitdiff
[power] Fix locking in device_{suspend,resume}
authorPatrick Mochel <mochel@osdl.org>
Thu, 21 Aug 2003 05:48:57 +0000 (22:48 -0700)
committerPatrick Mochel <mochel@osdl.org>
Thu, 21 Aug 2003 05:48:57 +0000 (22:48 -0700)
We don't need to protect against multiple suspend calls, since subsequent
ones will happen on an empty (or at worst - short) list.

drivers/base/power/resume.c
drivers/base/power/suspend.c

index 19c6387fec40893366273fcee8c8129b2264796a..9db84a9e41e3efe35030875161399ba5b7edba8e 100644 (file)
@@ -31,11 +31,13 @@ int resume_device(struct device * dev)
 /**
  *     device_resume - Restore state of each device in system.
  *
- *     Restore normal device state and release the dpm_sem.
+ *     Walk the dpm_off list, remove each entry, resume the device,
+ *     then add it to the dpm_active list. 
  */
 
 void device_resume(void)
 {
+       down(&dpm_sem);
        while(!list_empty(&dpm_off)) {
                struct list_head * entry = dpm_off.next;
                struct device * dev = to_device(entry);
index e9ca633fc12908811b1a6ae23597c2695e666b17..6da8cdd69dce08b318e667b3dd316c32b017cf06 100644 (file)
@@ -71,9 +71,6 @@ int suspend_device(struct device * dev, u32 state)
  *     b) prevent other PM operations from happening after we've begun.
  *     c) make sure we're exclusive when we disable interrupts.
  *
- *     device_resume() will release dpm_sem after restoring state to 
- *     all devices (as will this on error). You must call it once you've 
- *     called device_suspend().
  */
 
 int device_suspend(u32 state)
@@ -88,6 +85,7 @@ int device_suspend(u32 state)
                        goto Error;
        }
  Done:
+       up(&dpm_sem);
        return error;
  Error:
        device_resume();