Skip to content

Commit 6eded06

Browse files
mochel@digitalimplant.orggregkh
authored andcommitted
[PATCH] Fix up bus code and remove use of rwsem.
- Don't add devices to bus's embedded kset, since it's not used by anyone anymore. - Don't need to take the bus rwsem when calling {device,driver}_attach(), since those functions use the klists and the klists' spinlocks. Signed-off-by: Patrick Mochel <mochel@digitalimplant.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent d4a7537 commit 6eded06

1 file changed

Lines changed: 0 additions & 12 deletions

File tree

‎drivers/base/bus.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "base.h"
1818
#include "power/power.h"
1919

20-
#define to_dev(node) container_of(node, struct device, bus_list)
21-
2220
#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
2321
#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj)
2422

@@ -271,11 +269,8 @@ int bus_add_device(struct device * dev)
271269
int error = 0;
272270

273271
if (bus) {
274-
down_write(&dev->bus->subsys.rwsem);
275272
pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
276-
list_add_tail(&dev->bus_list, &dev->bus->devices.list);
277273
device_attach(dev);
278-
up_write(&dev->bus->subsys.rwsem);
279274
klist_add_tail(&bus->klist_devices, &dev->knode_bus);
280275
device_add_attrs(bus, dev);
281276
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
@@ -300,11 +295,8 @@ void bus_remove_device(struct device * dev)
300295
sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
301296
device_remove_attrs(dev->bus, dev);
302297
klist_remove(&dev->knode_bus);
303-
down_write(&dev->bus->subsys.rwsem);
304298
pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
305299
device_release_driver(dev);
306-
list_del_init(&dev->bus_list);
307-
up_write(&dev->bus->subsys.rwsem);
308300
put_bus(dev->bus);
309301
}
310302
}
@@ -364,9 +356,7 @@ int bus_add_driver(struct device_driver * drv)
364356
return error;
365357
}
366358

367-
down_write(&bus->subsys.rwsem);
368359
driver_attach(drv);
369-
up_write(&bus->subsys.rwsem);
370360
klist_add_tail(&bus->klist_drivers, &drv->knode_bus);
371361
module_add_driver(drv->owner, drv);
372362

@@ -390,10 +380,8 @@ void bus_remove_driver(struct device_driver * drv)
390380
if (drv->bus) {
391381
driver_remove_attrs(drv->bus, drv);
392382
klist_remove(&drv->knode_bus);
393-
down_write(&drv->bus->subsys.rwsem);
394383
pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
395384
driver_detach(drv);
396-
up_write(&drv->bus->subsys.rwsem);
397385
module_remove_driver(drv);
398386
kobject_unregister(&drv->kobj);
399387
put_bus(drv->bus);

0 commit comments

Comments
 (0)