summaryrefslogtreecommitdiffstats
path: root/drivers/base/dd.c
diff options
context:
space:
mode:
authormochel@digitalimplant.org <mochel@digitalimplant.org>2005-03-21 12:25:36 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-20 15:15:16 -0700
commit94e7b1c5ff2055571703e38b059afffe17658432 (patch)
tree469dbd920087ec62acd88b4985437a78c6786c0e /drivers/base/dd.c
parent38fdac3cdce276554b4484a41f8ec2daf81cb2ff (diff)
downloadlinux-94e7b1c5ff2055571703e38b059afffe17658432.tar.bz2
[PATCH] Add a klist to struct device_driver for the devices bound to it.
- Use it in driver_for_each_device() instead of the regular list_head and stop using the bus's rwsem for protection. - Use driver_for_each_device() in driver_detach() so we don't deadlock on the bus's rwsem. - Remove ->devices. - Move klist access and sysfs link access out from under device's semaphore, since they're synchronized through other means. Signed-off-by: Patrick Mochel <mochel@digitalimplant.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/dd.c')
-rw-r--r--drivers/base/dd.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index b709b1e0cb2a..47cbb5641235 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -40,7 +40,7 @@ void device_bind_driver(struct device * dev)
{
pr_debug("bound device '%s' to driver '%s'\n",
dev->bus_id, dev->driver->name);
- list_add_tail(&dev->driver_list, &dev->driver->devices);
+ klist_add_tail(&dev->driver->klist_devices, &dev->knode_driver);
sysfs_create_link(&dev->driver->kobj, &dev->kobj,
kobject_name(&dev->kobj));
sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
@@ -164,31 +164,35 @@ void driver_attach(struct device_driver * drv)
*/
void device_release_driver(struct device * dev)
{
- struct device_driver * drv;
+ struct device_driver * drv = dev->driver;
+
+ if (!drv)
+ return;
+
+ sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
+ sysfs_remove_link(&dev->kobj, "driver");
+ klist_remove(&dev->knode_driver);
down(&dev->sem);
- drv = dev->driver;
- if (drv) {
- sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
- sysfs_remove_link(&dev->kobj, "driver");
- list_del_init(&dev->driver_list);
- if (drv->remove)
- drv->remove(dev);
- dev->driver = NULL;
- }
+ if (drv->remove)
+ drv->remove(dev);
+ dev->driver = NULL;
up(&dev->sem);
}
+static int __remove_driver(struct device * dev, void * unused)
+{
+ device_release_driver(dev);
+ return 0;
+}
+
/**
* driver_detach - detach driver from all devices it controls.
* @drv: driver.
*/
void driver_detach(struct device_driver * drv)
{
- while (!list_empty(&drv->devices)) {
- struct device * dev = container_of(drv->devices.next, struct device, driver_list);
- device_release_driver(dev);
- }
+ driver_for_each_device(drv, NULL, NULL, __remove_driver);
}