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 <[email protected]>
Cc: Jean Delvare <[email protected]>
Cc: Dave Young <[email protected]>
Cc: Ming Lei <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: Phil Carmody <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Alan Stern <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Stefan Richter <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Vegard Nossum <[email protected]>
Cc: Jesse Barnes <[email protected]>
Cc: Alex Chiang <[email protected]>
Cc: Kenji Kaneshige <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andrew Patterson <[email protected]>
Cc: Yu Zhao <[email protected]>
Cc: Dominik Brodowski <[email protected]>
Cc: Samuel Ortiz <[email protected]>
Cc: Wolfram Sang <[email protected]>
Cc: CHENG Renquan <[email protected]>
Cc: Oliver Neukum <[email protected]>
Cc: Frans Pop <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Kay Sievers <[email protected]>
Cc: Sarah Sharp <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Greg Kroah-Hartman 2010-02-17 10:57:05 -08:00
commit 8e9394ce24
13 changed files with 76 additions and 63 deletions

View file

@ -62,12 +62,12 @@ int umc_controller_reset(struct umc_dev *umc)
struct device *parent = umc->dev.parent;
int ret = 0;
if(down_trylock(&parent->sem))
if (device_trylock(parent))
return -EAGAIN;
ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper);
if (ret >= 0)
ret = device_for_each_child(parent, parent, umc_bus_post_reset_helper);
up(&parent->sem);
device_unlock(parent);
return ret;
}

View file

@ -366,12 +366,12 @@ struct dentry *uwb_dbg_create_pal_dir(struct uwb_pal *pal);
static inline void uwb_dev_lock(struct uwb_dev *uwb_dev)
{
down(&uwb_dev->dev.sem);
device_lock(&uwb_dev->dev);
}
static inline void uwb_dev_unlock(struct uwb_dev *uwb_dev)
{
up(&uwb_dev->dev.sem);
device_unlock(&uwb_dev->dev);
}
#endif /* #ifndef __UWB_INTERNAL_H__ */