diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-02-17 13:57:05 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-07 20:04:52 -0500 |
commit | 8e9394ce2412254ec69fd2a4f3e44a66eade2297 (patch) | |
tree | 355f25148b4ce3f5cfebeaf0939d71cb6beaf88b /drivers/base/bus.c | |
parent | 62e877b893e6350c900d381f353aa62ed48dcc97 (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/bus.c')
-rw-r--r-- | drivers/base/bus.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index cca1aa10054c..71f6af5c8b0b 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -173,10 +173,10 @@ static ssize_t driver_unbind(struct device_driver *drv, | |||
173 | dev = bus_find_device_by_name(bus, NULL, buf); | 173 | dev = bus_find_device_by_name(bus, NULL, buf); |
174 | if (dev && dev->driver == drv) { | 174 | if (dev && dev->driver == drv) { |
175 | if (dev->parent) /* Needed for USB */ | 175 | if (dev->parent) /* Needed for USB */ |
176 | down(&dev->parent->sem); | 176 | device_lock(dev->parent); |
177 | device_release_driver(dev); | 177 | device_release_driver(dev); |
178 | if (dev->parent) | 178 | if (dev->parent) |
179 | up(&dev->parent->sem); | 179 | device_unlock(dev->parent); |
180 | err = count; | 180 | err = count; |
181 | } | 181 | } |
182 | put_device(dev); | 182 | put_device(dev); |
@@ -200,12 +200,12 @@ static ssize_t driver_bind(struct device_driver *drv, | |||
200 | dev = bus_find_device_by_name(bus, NULL, buf); | 200 | dev = bus_find_device_by_name(bus, NULL, buf); |
201 | if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { | 201 | if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { |
202 | if (dev->parent) /* Needed for USB */ | 202 | if (dev->parent) /* Needed for USB */ |
203 | down(&dev->parent->sem); | 203 | device_lock(dev->parent); |
204 | down(&dev->sem); | 204 | device_lock(dev); |
205 | err = driver_probe_device(drv, dev); | 205 | err = driver_probe_device(drv, dev); |
206 | up(&dev->sem); | 206 | device_unlock(dev); |
207 | if (dev->parent) | 207 | if (dev->parent) |
208 | up(&dev->parent->sem); | 208 | device_unlock(dev->parent); |
209 | 209 | ||
210 | if (err > 0) { | 210 | if (err > 0) { |
211 | /* success */ | 211 | /* success */ |
@@ -744,10 +744,10 @@ static int __must_check bus_rescan_devices_helper(struct device *dev, | |||
744 | 744 | ||
745 | if (!dev->driver) { | 745 | if (!dev->driver) { |
746 | if (dev->parent) /* Needed for USB */ | 746 | if (dev->parent) /* Needed for USB */ |
747 | down(&dev->parent->sem); | 747 | device_lock(dev->parent); |
748 | ret = device_attach(dev); | 748 | ret = device_attach(dev); |
749 | if (dev->parent) | 749 | if (dev->parent) |
750 | up(&dev->parent->sem); | 750 | device_unlock(dev->parent); |
751 | } | 751 | } |
752 | return ret < 0 ? ret : 0; | 752 | return ret < 0 ? ret : 0; |
753 | } | 753 | } |
@@ -779,10 +779,10 @@ int device_reprobe(struct device *dev) | |||
779 | { | 779 | { |
780 | if (dev->driver) { | 780 | if (dev->driver) { |
781 | if (dev->parent) /* Needed for USB */ | 781 | if (dev->parent) /* Needed for USB */ |
782 | down(&dev->parent->sem); | 782 | device_lock(dev->parent); |
783 | device_release_driver(dev); | 783 | device_release_driver(dev); |
784 | if (dev->parent) | 784 | if (dev->parent) |
785 | up(&dev->parent->sem); | 785 | device_unlock(dev->parent); |
786 | } | 786 | } |
787 | return bus_rescan_devices_helper(dev, NULL); | 787 | return bus_rescan_devices_helper(dev, NULL); |
788 | } | 788 | } |