diff options
Diffstat (limited to 'drivers/base/bus.c')
| -rw-r--r-- | drivers/base/bus.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 76656acd00d4..050d86d0b872 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
| @@ -362,8 +362,7 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev) | |||
| 362 | * @dev: device being added | 362 | * @dev: device being added |
| 363 | * | 363 | * |
| 364 | * - Add the device to its bus's list of devices. | 364 | * - Add the device to its bus's list of devices. |
| 365 | * - Try to attach to driver. | 365 | * - Create link to device's bus. |
| 366 | * - Create link to device's physical location. | ||
| 367 | */ | 366 | */ |
| 368 | int bus_add_device(struct device * dev) | 367 | int bus_add_device(struct device * dev) |
| 369 | { | 368 | { |
| @@ -372,11 +371,10 @@ int bus_add_device(struct device * dev) | |||
| 372 | 371 | ||
| 373 | if (bus) { | 372 | if (bus) { |
| 374 | pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); | 373 | pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); |
| 375 | device_attach(dev); | ||
| 376 | klist_add_tail(&dev->knode_bus, &bus->klist_devices); | ||
| 377 | error = device_add_attrs(bus, dev); | 374 | error = device_add_attrs(bus, dev); |
| 378 | if (!error) { | 375 | if (!error) { |
| 379 | sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); | 376 | sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); |
| 377 | sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "subsystem"); | ||
| 380 | sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus"); | 378 | sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus"); |
| 381 | } | 379 | } |
| 382 | } | 380 | } |
| @@ -384,6 +382,22 @@ int bus_add_device(struct device * dev) | |||
| 384 | } | 382 | } |
| 385 | 383 | ||
| 386 | /** | 384 | /** |
| 385 | * bus_attach_device - add device to bus | ||
| 386 | * @dev: device tried to attach to a driver | ||
| 387 | * | ||
| 388 | * - Try to attach to driver. | ||
| 389 | */ | ||
| 390 | void bus_attach_device(struct device * dev) | ||
| 391 | { | ||
| 392 | struct bus_type * bus = dev->bus; | ||
| 393 | |||
| 394 | if (bus) { | ||
| 395 | device_attach(dev); | ||
| 396 | klist_add_tail(&dev->knode_bus, &bus->klist_devices); | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | /** | ||
| 387 | * bus_remove_device - remove device from bus | 401 | * bus_remove_device - remove device from bus |
| 388 | * @dev: device to be removed | 402 | * @dev: device to be removed |
| 389 | * | 403 | * |
| @@ -395,6 +409,7 @@ int bus_add_device(struct device * dev) | |||
| 395 | void bus_remove_device(struct device * dev) | 409 | void bus_remove_device(struct device * dev) |
| 396 | { | 410 | { |
| 397 | if (dev->bus) { | 411 | if (dev->bus) { |
| 412 | sysfs_remove_link(&dev->kobj, "subsystem"); | ||
| 398 | sysfs_remove_link(&dev->kobj, "bus"); | 413 | sysfs_remove_link(&dev->kobj, "bus"); |
| 399 | sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); | 414 | sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); |
| 400 | device_remove_attrs(dev->bus, dev); | 415 | device_remove_attrs(dev->bus, dev); |
| @@ -732,14 +747,9 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev); | |||
| 732 | EXPORT_SYMBOL_GPL(bus_find_device); | 747 | EXPORT_SYMBOL_GPL(bus_find_device); |
| 733 | EXPORT_SYMBOL_GPL(bus_for_each_drv); | 748 | EXPORT_SYMBOL_GPL(bus_for_each_drv); |
| 734 | 749 | ||
| 735 | EXPORT_SYMBOL_GPL(bus_add_device); | ||
| 736 | EXPORT_SYMBOL_GPL(bus_remove_device); | ||
| 737 | EXPORT_SYMBOL_GPL(bus_register); | 750 | EXPORT_SYMBOL_GPL(bus_register); |
| 738 | EXPORT_SYMBOL_GPL(bus_unregister); | 751 | EXPORT_SYMBOL_GPL(bus_unregister); |
| 739 | EXPORT_SYMBOL_GPL(bus_rescan_devices); | 752 | EXPORT_SYMBOL_GPL(bus_rescan_devices); |
| 740 | EXPORT_SYMBOL_GPL(get_bus); | ||
| 741 | EXPORT_SYMBOL_GPL(put_bus); | ||
| 742 | EXPORT_SYMBOL_GPL(find_bus); | ||
| 743 | 753 | ||
| 744 | EXPORT_SYMBOL_GPL(bus_create_file); | 754 | EXPORT_SYMBOL_GPL(bus_create_file); |
| 745 | EXPORT_SYMBOL_GPL(bus_remove_file); | 755 | EXPORT_SYMBOL_GPL(bus_remove_file); |
