aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/main.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2010-02-17 13:57:05 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-07 20:04:52 -0500
commit8e9394ce2412254ec69fd2a4f3e44a66eade2297 (patch)
tree355f25148b4ce3f5cfebeaf0939d71cb6beaf88b /drivers/base/power/main.c
parent62e877b893e6350c900d381f353aa62ed48dcc97 (diff)
Driver core: create lock/unlock functions for struct device
In the future, we are going to be changing the lock type for struct device (once we get the lockdep infrastructure properly worked out) To make that changeover easier, and to possibly burry the lock in a different part of struct device, let's create some functions to lock and unlock a device so that no out-of-core code needs to be changed in the future. This patch creates the device_lock/unlock/trylock() functions, and converts all in-tree users to them. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jean Delvare <khali@linux-fr.org> Cc: Dave Young <hidave.darkstar@gmail.com> Cc: Ming Lei <tom.leiming@gmail.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Phil Carmody <ext-phil.2.carmody@nokia.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Rafael J. Wysocki <rjw@sisk.pl> Cc: Pavel Machek <pavel@ucw.cz> Cc: Len Brown <len.brown@intel.com> Cc: Magnus Damm <damm@igel.co.jp> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Randy Dunlap <randy.dunlap@oracle.com> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Vegard Nossum <vegard.nossum@gmail.com> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Alex Chiang <achiang@hp.com> Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andrew Patterson <andrew.patterson@hp.com> Cc: Yu Zhao <yu.zhao@intel.com> Cc: Dominik Brodowski <linux@dominikbrodowski.net> Cc: Samuel Ortiz <sameo@linux.intel.com> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: CHENG Renquan <rqcheng@smu.edu.sg> Cc: Oliver Neukum <oliver@neukum.org> Cc: Frans Pop <elendil@planet.nl> Cc: David Vrabel <david.vrabel@csr.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/power/main.c')
-rw-r--r--drivers/base/power/main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 0e26a6f6fd48..d477f4dc5e51 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -35,8 +35,8 @@
35 * because children are guaranteed to be discovered after parents, and 35 * because children are guaranteed to be discovered after parents, and
36 * are inserted at the back of the list on discovery. 36 * are inserted at the back of the list on discovery.
37 * 37 *
38 * Since device_pm_add() may be called with a device semaphore held, 38 * Since device_pm_add() may be called with a device lock held,
39 * we must never try to acquire a device semaphore while holding 39 * we must never try to acquire a device lock while holding
40 * dpm_list_mutex. 40 * dpm_list_mutex.
41 */ 41 */
42 42
@@ -508,7 +508,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
508 TRACE_RESUME(0); 508 TRACE_RESUME(0);
509 509
510 dpm_wait(dev->parent, async); 510 dpm_wait(dev->parent, async);
511 down(&dev->sem); 511 device_lock(dev);
512 512
513 dev->power.status = DPM_RESUMING; 513 dev->power.status = DPM_RESUMING;
514 514
@@ -543,7 +543,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
543 } 543 }
544 } 544 }
545 End: 545 End:
546 up(&dev->sem); 546 device_unlock(dev);
547 complete_all(&dev->power.completion); 547 complete_all(&dev->power.completion);
548 548
549 TRACE_RESUME(error); 549 TRACE_RESUME(error);
@@ -629,7 +629,7 @@ static void dpm_resume(pm_message_t state)
629 */ 629 */
630static void device_complete(struct device *dev, pm_message_t state) 630static void device_complete(struct device *dev, pm_message_t state)
631{ 631{
632 down(&dev->sem); 632 device_lock(dev);
633 633
634 if (dev->class && dev->class->pm && dev->class->pm->complete) { 634 if (dev->class && dev->class->pm && dev->class->pm->complete) {
635 pm_dev_dbg(dev, state, "completing class "); 635 pm_dev_dbg(dev, state, "completing class ");
@@ -646,7 +646,7 @@ static void device_complete(struct device *dev, pm_message_t state)
646 dev->bus->pm->complete(dev); 646 dev->bus->pm->complete(dev);
647 } 647 }
648 648
649 up(&dev->sem); 649 device_unlock(dev);
650} 650}
651 651
652/** 652/**
@@ -809,7 +809,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
809 int error = 0; 809 int error = 0;
810 810
811 dpm_wait_for_children(dev, async); 811 dpm_wait_for_children(dev, async);
812 down(&dev->sem); 812 device_lock(dev);
813 813
814 if (async_error) 814 if (async_error)
815 goto End; 815 goto End;
@@ -849,7 +849,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
849 dev->power.status = DPM_OFF; 849 dev->power.status = DPM_OFF;
850 850
851 End: 851 End:
852 up(&dev->sem); 852 device_unlock(dev);
853 complete_all(&dev->power.completion); 853 complete_all(&dev->power.completion);
854 854
855 return error; 855 return error;
@@ -938,7 +938,7 @@ static int device_prepare(struct device *dev, pm_message_t state)
938{ 938{
939 int error = 0; 939 int error = 0;
940 940
941 down(&dev->sem); 941 device_lock(dev);
942 942
943 if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) { 943 if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) {
944 pm_dev_dbg(dev, state, "preparing "); 944 pm_dev_dbg(dev, state, "preparing ");
@@ -962,7 +962,7 @@ static int device_prepare(struct device *dev, pm_message_t state)
962 suspend_report_result(dev->class->pm->prepare, error); 962 suspend_report_result(dev->class->pm->prepare, error);
963 } 963 }
964 End: 964 End:
965 up(&dev->sem); 965 device_unlock(dev);
966 966
967 return error; 967 return error;
968} 968}