aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-11-01 16:31:26 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:16 -0500
commit6dcec2511ff55b4abaca7ad3433011a7c04c2430 (patch)
treeaeb9c18a877987478a1594d42b8f041ebb388875 /drivers/base/bus.c
parent3d8995963dfec66ef6270e729bf75903e9043f9d (diff)
kset: convert struct bus_device->drivers to use kset_create
Dynamically create the kset instead of declaring it statically. Having 3 static kobjects in one structure is not only foolish, but ripe for nasty race conditions if handled improperly. We also rename the field to catch any potential users of it (not that there should be outside of the driver core...) Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index b23eeb2d4ead..6796d3e46053 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -638,7 +638,7 @@ int bus_add_driver(struct device_driver *drv)
638 error = kobject_set_name(&drv->kobj, "%s", drv->name); 638 error = kobject_set_name(&drv->kobj, "%s", drv->name);
639 if (error) 639 if (error)
640 goto out_put_bus; 640 goto out_put_bus;
641 drv->kobj.kset = &bus->drivers; 641 drv->kobj.kset = bus->drivers_kset;
642 drv->kobj.ktype = &driver_ktype; 642 drv->kobj.ktype = &driver_ktype;
643 error = kobject_register(&drv->kobj); 643 error = kobject_register(&drv->kobj);
644 if (error) 644 if (error)
@@ -869,11 +869,12 @@ int bus_register(struct bus_type * bus)
869 goto bus_devices_fail; 869 goto bus_devices_fail;
870 } 870 }
871 871
872 kobject_set_name(&bus->drivers.kobj, "drivers"); 872 bus->drivers_kset = kset_create_and_add("drivers", NULL,
873 bus->drivers.kobj.parent = &bus->subsys.kobj; 873 &bus->subsys.kobj);
874 retval = kset_register(&bus->drivers); 874 if (!bus->drivers_kset) {
875 if (retval) 875 retval = -ENOMEM;
876 goto bus_drivers_fail; 876 goto bus_drivers_fail;
877 }
877 878
878 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put); 879 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
879 klist_init(&bus->klist_drivers, NULL, NULL); 880 klist_init(&bus->klist_drivers, NULL, NULL);
@@ -893,7 +894,7 @@ int bus_register(struct bus_type * bus)
893bus_attrs_fail: 894bus_attrs_fail:
894 remove_probe_files(bus); 895 remove_probe_files(bus);
895bus_probe_files_fail: 896bus_probe_files_fail:
896 kset_unregister(&bus->drivers); 897 kset_unregister(bus->drivers_kset);
897bus_drivers_fail: 898bus_drivers_fail:
898 kset_unregister(bus->devices_kset); 899 kset_unregister(bus->devices_kset);
899bus_devices_fail: 900bus_devices_fail:
@@ -916,7 +917,7 @@ void bus_unregister(struct bus_type * bus)
916 pr_debug("bus %s: unregistering\n", bus->name); 917 pr_debug("bus %s: unregistering\n", bus->name);
917 bus_remove_attrs(bus); 918 bus_remove_attrs(bus);
918 remove_probe_files(bus); 919 remove_probe_files(bus);
919 kset_unregister(&bus->drivers); 920 kset_unregister(bus->drivers_kset);
920 kset_unregister(bus->devices_kset); 921 kset_unregister(bus->devices_kset);
921 bus_remove_file(bus, &bus_attr_uevent); 922 bus_remove_file(bus, &bus_attr_uevent);
922 subsystem_unregister(&bus->subsys); 923 subsystem_unregister(&bus->subsys);