diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-11-01 16:31:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:16 -0500 |
commit | 3d8995963dfec66ef6270e729bf75903e9043f9d (patch) | |
tree | 3abf600f400fb1bbc26f0be4f43af6cb22d24ce4 /drivers/base/bus.c | |
parent | 039a5dcd2fc45188a2d522df630db4f7ef903a0f (diff) |
kset: convert struct bus_device->devices 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.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index e3b101077804..b23eeb2d4ead 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -449,7 +449,7 @@ int bus_add_device(struct device * dev) | |||
449 | error = device_add_attrs(bus, dev); | 449 | error = device_add_attrs(bus, dev); |
450 | if (error) | 450 | if (error) |
451 | goto out_put; | 451 | goto out_put; |
452 | error = sysfs_create_link(&bus->devices.kobj, | 452 | error = sysfs_create_link(&bus->devices_kset->kobj, |
453 | &dev->kobj, dev->bus_id); | 453 | &dev->kobj, dev->bus_id); |
454 | if (error) | 454 | if (error) |
455 | goto out_id; | 455 | goto out_id; |
@@ -466,7 +466,7 @@ int bus_add_device(struct device * dev) | |||
466 | out_deprecated: | 466 | out_deprecated: |
467 | sysfs_remove_link(&dev->kobj, "subsystem"); | 467 | sysfs_remove_link(&dev->kobj, "subsystem"); |
468 | out_subsys: | 468 | out_subsys: |
469 | sysfs_remove_link(&bus->devices.kobj, dev->bus_id); | 469 | sysfs_remove_link(&bus->devices_kset->kobj, dev->bus_id); |
470 | out_id: | 470 | out_id: |
471 | device_remove_attrs(bus, dev); | 471 | device_remove_attrs(bus, dev); |
472 | out_put: | 472 | out_put: |
@@ -512,7 +512,7 @@ void bus_remove_device(struct device * dev) | |||
512 | if (dev->bus) { | 512 | if (dev->bus) { |
513 | sysfs_remove_link(&dev->kobj, "subsystem"); | 513 | sysfs_remove_link(&dev->kobj, "subsystem"); |
514 | remove_deprecated_bus_links(dev); | 514 | remove_deprecated_bus_links(dev); |
515 | sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); | 515 | sysfs_remove_link(&dev->bus->devices_kset->kobj, dev->bus_id); |
516 | device_remove_attrs(dev->bus, dev); | 516 | device_remove_attrs(dev->bus, dev); |
517 | if (dev->is_registered) { | 517 | if (dev->is_registered) { |
518 | dev->is_registered = 0; | 518 | dev->is_registered = 0; |
@@ -862,11 +862,12 @@ int bus_register(struct bus_type * bus) | |||
862 | if (retval) | 862 | if (retval) |
863 | goto bus_uevent_fail; | 863 | goto bus_uevent_fail; |
864 | 864 | ||
865 | kobject_set_name(&bus->devices.kobj, "devices"); | 865 | bus->devices_kset = kset_create_and_add("devices", NULL, |
866 | bus->devices.kobj.parent = &bus->subsys.kobj; | 866 | &bus->subsys.kobj); |
867 | retval = kset_register(&bus->devices); | 867 | if (!bus->devices_kset) { |
868 | if (retval) | 868 | retval = -ENOMEM; |
869 | goto bus_devices_fail; | 869 | goto bus_devices_fail; |
870 | } | ||
870 | 871 | ||
871 | kobject_set_name(&bus->drivers.kobj, "drivers"); | 872 | kobject_set_name(&bus->drivers.kobj, "drivers"); |
872 | bus->drivers.kobj.parent = &bus->subsys.kobj; | 873 | bus->drivers.kobj.parent = &bus->subsys.kobj; |
@@ -894,7 +895,7 @@ bus_attrs_fail: | |||
894 | bus_probe_files_fail: | 895 | bus_probe_files_fail: |
895 | kset_unregister(&bus->drivers); | 896 | kset_unregister(&bus->drivers); |
896 | bus_drivers_fail: | 897 | bus_drivers_fail: |
897 | kset_unregister(&bus->devices); | 898 | kset_unregister(bus->devices_kset); |
898 | bus_devices_fail: | 899 | bus_devices_fail: |
899 | bus_remove_file(bus, &bus_attr_uevent); | 900 | bus_remove_file(bus, &bus_attr_uevent); |
900 | bus_uevent_fail: | 901 | bus_uevent_fail: |
@@ -916,7 +917,7 @@ void bus_unregister(struct bus_type * bus) | |||
916 | bus_remove_attrs(bus); | 917 | bus_remove_attrs(bus); |
917 | remove_probe_files(bus); | 918 | remove_probe_files(bus); |
918 | kset_unregister(&bus->drivers); | 919 | kset_unregister(&bus->drivers); |
919 | kset_unregister(&bus->devices); | 920 | kset_unregister(bus->devices_kset); |
920 | bus_remove_file(bus, &bus_attr_uevent); | 921 | bus_remove_file(bus, &bus_attr_uevent); |
921 | subsystem_unregister(&bus->subsys); | 922 | subsystem_unregister(&bus->subsys); |
922 | } | 923 | } |