diff options
| author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-02-17 11:02:55 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-02-17 11:02:55 -0800 |
| commit | a9791f90d6c16d5cdec9f6213571c9699c1a85d2 (patch) | |
| tree | 78e3df2cd011230b895fed677608a75e94ccddc4 | |
| parent | 937fa613780b0c567c7274f84427d25713804b8e (diff) | |
| download | patches-a9791f90d6c16d5cdec9f6213571c9699c1a85d2.tar.gz | |
locking api changes for the driver core
| -rw-r--r-- | driver-core/drivers-base-convert-sema.patch | 464 | ||||
| -rw-r--r-- | series | 1 |
2 files changed, 29 insertions, 436 deletions
diff --git a/driver-core/drivers-base-convert-sema.patch b/driver-core/drivers-base-convert-sema.patch index 215442f033e9f1..5be607bb49c2e6 100644 --- a/driver-core/drivers-base-convert-sema.patch +++ b/driver-core/drivers-base-convert-sema.patch @@ -8,89 +8,21 @@ Content-Disposition: inline; filename=drivers-base-convert-sema.patch The semaphore is semantically a mutex. Convert it to a real mutex and -clean up all users outside of drivers/base as well. +fix up a few places where code was relying on semaphore.h to be included +by device.h, as well as the users of the trylock function, as that value +is now reversed. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- - drivers/base/bus.c | 20 ++++++------ - drivers/base/core.c | 3 - - drivers/base/dd.c | 38 +++++++++++------------ - drivers/base/power/main.c | 20 ++++++------ - drivers/firewire/core-device.c | 4 +- - drivers/ieee1394/nodemgr.c | 4 +- - drivers/net/mlx4/mlx4.h | 1 - drivers/pci/bus.c | 4 +- - drivers/pci/pci.c | 4 +- - drivers/pcmcia/ds.c | 8 ++-- - drivers/staging/comedi/drivers/quatech_daqp_cs.c | 1 - drivers/usb/core/driver.c | 4 +- - drivers/usb/core/usb.c | 2 - - drivers/uwb/umc-bus.c | 4 +- - drivers/uwb/uwb-internal.h | 4 +- - include/linux/device.h | 5 +-- - include/linux/usb.h | 6 +-- - 17 files changed, 66 insertions(+), 66 deletions(-) + drivers/base/core.c | 3 +-- + drivers/net/mlx4/mlx4.h | 1 + + drivers/staging/comedi/drivers/quatech_daqp_cs.c | 1 + + drivers/usb/core/usb.c | 2 +- + include/linux/device.h | 9 ++++----- + 5 files changed, 8 insertions(+), 8 deletions(-) ---- a/drivers/base/bus.c -+++ b/drivers/base/bus.c -@@ -173,10 +173,10 @@ static ssize_t driver_unbind(struct devi - dev = bus_find_device_by_name(bus, NULL, buf); - if (dev && dev->driver == drv) { - if (dev->parent) /* Needed for USB */ -- down(&dev->parent->sem); -+ mutex_lock(&dev->parent->mutex); - device_release_driver(dev); - if (dev->parent) -- up(&dev->parent->sem); -+ mutex_unlock(&dev->parent->mutex); - err = count; - } - put_device(dev); -@@ -200,12 +200,12 @@ static ssize_t driver_bind(struct device - dev = bus_find_device_by_name(bus, NULL, buf); - if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { - if (dev->parent) /* Needed for USB */ -- down(&dev->parent->sem); -- down(&dev->sem); -+ mutex_lock(&dev->parent->mutex); -+ mutex_lock(&dev->mutex); - err = driver_probe_device(drv, dev); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - if (dev->parent) -- up(&dev->parent->sem); -+ mutex_unlock(&dev->parent->mutex); - - if (err > 0) { - /* success */ -@@ -744,10 +744,10 @@ static int __must_check bus_rescan_devic - - if (!dev->driver) { - if (dev->parent) /* Needed for USB */ -- down(&dev->parent->sem); -+ mutex_lock(&dev->parent->mutex); - ret = device_attach(dev); - if (dev->parent) -- up(&dev->parent->sem); -+ mutex_unlock(&dev->parent->mutex); - } - return ret < 0 ? ret : 0; - } -@@ -779,10 +779,10 @@ int device_reprobe(struct device *dev) - { - if (dev->driver) { - if (dev->parent) /* Needed for USB */ -- down(&dev->parent->sem); -+ mutex_lock(&dev->parent->mutex); - device_release_driver(dev); - if (dev->parent) -- up(&dev->parent->sem); -+ mutex_unlock(&dev->parent->mutex); - } - return bus_rescan_devices_helper(dev, NULL); - } --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -20,7 +20,6 @@ @@ -110,234 +42,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> spin_lock_init(&dev->devres_lock); INIT_LIST_HEAD(&dev->devres_head); device_init_wakeup(dev, 0); ---- a/drivers/base/dd.c -+++ b/drivers/base/dd.c -@@ -85,7 +85,7 @@ static void driver_sysfs_remove(struct d - * for before calling this. (It is ok to call with no other effort - * from a driver's probe() method.) - * -- * This function must be called with @dev->sem held. -+ * This function must be called with @dev->mutex held. - */ - int device_bind_driver(struct device *dev) - { -@@ -190,8 +190,8 @@ EXPORT_SYMBOL_GPL(wait_for_device_probe) - * This function returns -ENODEV if the device is not registered, - * 1 if the device is bound successfully and 0 otherwise. - * -- * This function must be called with @dev->sem held. When called for a -- * USB interface, @dev->parent->sem must be held as well. -+ * This function must be called with @dev->mutex held. When called for a -+ * USB interface, @dev->parent->mutex must be held as well. - */ - int driver_probe_device(struct device_driver *drv, struct device *dev) - { -@@ -233,13 +233,13 @@ static int __device_attach(struct device - * 0 if no matching driver was found; - * -ENODEV if the device is not registered. - * -- * When called for a USB interface, @dev->parent->sem must be held. -+ * When called for a USB interface, @dev->parent->mutex must be held. - */ - int device_attach(struct device *dev) - { - int ret = 0; - -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - if (dev->driver) { - ret = device_bind_driver(dev); - if (ret == 0) -@@ -253,7 +253,7 @@ int device_attach(struct device *dev) - ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); - pm_runtime_put_sync(dev); - } -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - return ret; - } - EXPORT_SYMBOL_GPL(device_attach); -@@ -276,13 +276,13 @@ static int __driver_attach(struct device - return 0; - - if (dev->parent) /* Needed for USB */ -- down(&dev->parent->sem); -- down(&dev->sem); -+ mutex_lock(&dev->parent->mutex); -+ mutex_lock(&dev->mutex); - if (!dev->driver) - driver_probe_device(drv, dev); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - if (dev->parent) -- up(&dev->parent->sem); -+ mutex_unlock(&dev->parent->mutex); - - return 0; - } -@@ -303,8 +303,8 @@ int driver_attach(struct device_driver * - EXPORT_SYMBOL_GPL(driver_attach); - - /* -- * __device_release_driver() must be called with @dev->sem held. -- * When called for a USB interface, @dev->parent->sem must be held as well. -+ * __device_release_driver() must be called with @dev->mutex held. -+ * When called for a USB interface, @dev->parent->mutex must be held as well. - */ - static void __device_release_driver(struct device *dev) - { -@@ -343,7 +343,7 @@ static void __device_release_driver(stru - * @dev: device. - * - * Manually detach device from driver. -- * When called for a USB interface, @dev->parent->sem must be held. -+ * When called for a USB interface, @dev->parent->mutex must be held. - */ - void device_release_driver(struct device *dev) - { -@@ -352,9 +352,9 @@ void device_release_driver(struct device - * within their ->remove callback for the same device, they - * will deadlock right here. - */ -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - __device_release_driver(dev); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - } - EXPORT_SYMBOL_GPL(device_release_driver); - -@@ -381,13 +381,13 @@ void driver_detach(struct device_driver - spin_unlock(&drv->p->klist_devices.k_lock); - - if (dev->parent) /* Needed for USB */ -- down(&dev->parent->sem); -- down(&dev->sem); -+ mutex_lock(&dev->parent->mutex); -+ mutex_lock(&dev->mutex); - if (dev->driver == drv) - __device_release_driver(dev); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - if (dev->parent) -- up(&dev->parent->sem); -+ mutex_unlock(&dev->parent->mutex); - put_device(dev); - } - } ---- a/drivers/base/power/main.c -+++ b/drivers/base/power/main.c -@@ -34,8 +34,8 @@ - * because children are guaranteed to be discovered after parents, and - * are inserted at the back of the list on discovery. - * -- * Since device_pm_add() may be called with a device semaphore held, -- * we must never try to acquire a device semaphore while holding -+ * Since device_pm_add() may be called with a device mutex held, -+ * we must never try to acquire a device mutex while holding - * dpm_list_mutex. - */ - -@@ -476,7 +476,7 @@ static int device_resume(struct device * - TRACE_DEVICE(dev); - TRACE_RESUME(0); - -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - - if (dev->bus) { - if (dev->bus->pm) { -@@ -509,7 +509,7 @@ static int device_resume(struct device * - } - } - End: -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - - TRACE_RESUME(error); - return error; -@@ -564,7 +564,7 @@ static void dpm_resume(pm_message_t stat - */ - static void device_complete(struct device *dev, pm_message_t state) - { -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - - if (dev->class && dev->class->pm && dev->class->pm->complete) { - pm_dev_dbg(dev, state, "completing class "); -@@ -581,7 +581,7 @@ static void device_complete(struct devic - dev->bus->pm->complete(dev); - } - -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - } - - /** -@@ -740,7 +740,7 @@ static int device_suspend(struct device - { - int error = 0; - -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - - if (dev->class) { - if (dev->class->pm) { -@@ -773,7 +773,7 @@ static int device_suspend(struct device - } - } - End: -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - - return error; - } -@@ -828,7 +828,7 @@ static int device_prepare(struct device - { - int error = 0; - -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - - if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) { - pm_dev_dbg(dev, state, "preparing "); -@@ -852,7 +852,7 @@ static int device_prepare(struct device - suspend_report_result(dev->class->pm->prepare, error); - } - End: -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - - return error; - } ---- a/drivers/firewire/core-device.c -+++ b/drivers/firewire/core-device.c -@@ -762,9 +762,9 @@ static int update_unit(struct device *de - struct fw_driver *driver = (struct fw_driver *)dev->driver; - - if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) { -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - driver->update(unit); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - } - - return 0; ---- a/drivers/ieee1394/nodemgr.c -+++ b/drivers/ieee1394/nodemgr.c -@@ -1397,9 +1397,9 @@ static int update_pdrv(struct device *de - pdrv = container_of(drv, struct hpsb_protocol_driver, - driver); - if (pdrv->update) { -- down(&ud->device.sem); -+ mutex_lock(&ud->device.mutex); - error = pdrv->update(ud); -- up(&ud->device.sem); -+ mutex_unlock(&ud->device.mutex); - } - if (error) - device_release_driver(&ud->device); --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -40,6 +40,7 @@ @@ -348,66 +52,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> #include <linux/workqueue.h> #include <linux/mlx4/device.h> ---- a/drivers/pci/bus.c -+++ b/drivers/pci/bus.c -@@ -240,9 +240,9 @@ void pci_walk_bus(struct pci_bus *top, i - next = dev->bus_list.next; - - /* Run device routines with the device locked */ -- down(&dev->dev.sem); -+ mutex_lock(&dev->dev.mutex); - retval = cb(dev, userdata); -- up(&dev->dev.sem); -+ mutex_unlock(&dev->dev.mutex); - if (retval) - break; - } ---- a/drivers/pci/pci.c -+++ b/drivers/pci/pci.c -@@ -2304,7 +2304,7 @@ static int pci_dev_reset(struct pci_dev - if (!probe) { - pci_block_user_cfg_access(dev); - /* block PM suspend, driver probe, etc. */ -- down(&dev->dev.sem); -+ mutex_lock(&dev->dev.mutex); - } - - rc = pci_dev_specific_reset(dev, probe); -@@ -2326,7 +2326,7 @@ static int pci_dev_reset(struct pci_dev - rc = pci_parent_bus_reset(dev, probe); - done: - if (!probe) { -- up(&dev->dev.sem); -+ mutex_unlock(&dev->dev.mutex); - pci_unblock_user_cfg_access(dev); - } - ---- a/drivers/pcmcia/ds.c -+++ b/drivers/pcmcia/ds.c -@@ -964,9 +964,9 @@ static int runtime_suspend(struct device - { - int rc; - -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - return rc; - } - -@@ -974,9 +974,9 @@ static void runtime_resume(struct device - { - int rc; - -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - rc = pcmcia_dev_resume(dev); -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - } - - /************************ per-device sysfs output ***************************/ --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -48,6 +48,7 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP @@ -418,21 +62,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> #include <pcmcia/cs_types.h> #include <pcmcia/cs.h> ---- a/drivers/usb/core/driver.c -+++ b/drivers/usb/core/driver.c -@@ -470,10 +470,10 @@ void usb_driver_release_interface(struct - if (device_is_registered(dev)) { - device_release_driver(dev); - } else { -- down(&dev->sem); -+ mutex_lock(&dev->mutex); - usb_unbind_interface(dev); - dev->driver = NULL; -- up(&dev->sem); -+ mutex_unlock(&dev->mutex); - } - } - EXPORT_SYMBOL_GPL(usb_driver_release_interface); --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -601,7 +601,7 @@ int usb_lock_device_for_reset(struct usb @@ -444,40 +73,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> /* If we can't acquire the lock after waiting one second, * we're probably deadlocked */ ---- a/drivers/uwb/umc-bus.c -+++ b/drivers/uwb/umc-bus.c -@@ -62,12 +62,12 @@ int umc_controller_reset(struct umc_dev - struct device *parent = umc->dev.parent; - int ret = 0; - -- if(down_trylock(&parent->sem)) -+ if (!mutex_trylock(&parent->mutex)) - 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); -+ mutex_unlock(&parent->mutex); - - return ret; - } ---- a/drivers/uwb/uwb-internal.h -+++ b/drivers/uwb/uwb-internal.h -@@ -366,12 +366,12 @@ struct dentry *uwb_dbg_create_pal_dir(st - - static inline void uwb_dev_lock(struct uwb_dev *uwb_dev) - { -- down(&uwb_dev->dev.sem); -+ mutex_lock(&uwb_dev->dev.mutex); - } - - static inline void uwb_dev_unlock(struct uwb_dev *uwb_dev) - { -- up(&uwb_dev->dev.sem); -+ mutex_unlock(&uwb_dev->dev.mutex); - } - - #endif /* #ifndef __UWB_INTERNAL_H__ */ --- a/include/linux/device.h +++ b/include/linux/device.h @@ -22,7 +22,6 @@ @@ -488,15 +83,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> #include <asm/atomic.h> #include <asm/device.h> -@@ -106,7 +105,7 @@ extern int bus_unregister_notifier(struc - - /* All 4 notifers below get called with the target struct device * - * as an argument. Note that those functions are likely to be called -- * with the device semaphore held in the core, so be careful. -+ * with the device mutex held in the core, so be careful. - */ - #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ - #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ @@ -404,7 +403,7 @@ struct device { const char *init_name; /* initial name of the device */ struct device_type *type; @@ -506,18 +92,24 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> * its driver. */ ---- a/include/linux/usb.h -+++ b/include/linux/usb.h -@@ -527,9 +527,9 @@ extern struct usb_device *usb_get_dev(st - extern void usb_put_dev(struct usb_device *dev); +@@ -493,17 +492,17 @@ static inline int device_is_registered(s + + static inline void device_lock(struct device *dev) + { +- down(&dev->sem); ++ mutex_lock(&dev->mutex); + } + + static inline int device_trylock(struct device *dev) + { +- return down_trylock(&dev->sem); ++ return mutex_trylock(&dev->mutex); + } - /* USB device locking */ --#define usb_lock_device(udev) down(&(udev)->dev.sem) --#define usb_unlock_device(udev) up(&(udev)->dev.sem) --#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) -+#define usb_lock_device(udev) mutex_lock(&(udev)->dev.mutex) -+#define usb_unlock_device(udev) mutex_unlock(&(udev)->dev.mutex) -+#define usb_trylock_device(udev) mutex_trylock(&(udev)->dev.mutex) - extern int usb_lock_device_for_reset(struct usb_device *udev, - const struct usb_interface *iface); + static inline void device_unlock(struct device *dev) + { +- up(&dev->sem); ++ mutex_unlock(&dev->mutex); + } + void driver_init(void); @@ -77,6 +77,7 @@ driver-core/howto-updates-on-subsystem-trees-patchwork-next-vs.-mm.patch driver-core/sysdev-fix-up-the-probe-release-attributes.patch driver-core/driver-core-constify-struct-sysfs_ops-in-struct-kobj_type.patch driver-core/driver-core-make-struct-platform_driver.id_table-const.patch +driver-core/driver-core-create-lock-unlock-functions-for-struct-device.patch driver-core/drivers-base-convert-sema.patch # sent to Lennart 01-15-2010 |
