aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index aa685a20b649..636af538a2b5 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -392,6 +392,7 @@ out:
392 * bus_attach_device - add device to bus 392 * bus_attach_device - add device to bus
393 * @dev: device tried to attach to a driver 393 * @dev: device tried to attach to a driver
394 * 394 *
395 * - Add device to bus's list of devices.
395 * - Try to attach to driver. 396 * - Try to attach to driver.
396 */ 397 */
397int bus_attach_device(struct device * dev) 398int bus_attach_device(struct device * dev)
@@ -400,11 +401,13 @@ int bus_attach_device(struct device * dev)
400 int ret = 0; 401 int ret = 0;
401 402
402 if (bus) { 403 if (bus) {
404 dev->is_registered = 1;
403 ret = device_attach(dev); 405 ret = device_attach(dev);
404 if (ret >= 0) { 406 if (ret >= 0) {
405 klist_add_tail(&dev->knode_bus, &bus->klist_devices); 407 klist_add_tail(&dev->knode_bus, &bus->klist_devices);
406 ret = 0; 408 ret = 0;
407 } 409 } else
410 dev->is_registered = 0;
408 } 411 }
409 return ret; 412 return ret;
410} 413}
@@ -425,7 +428,8 @@ void bus_remove_device(struct device * dev)
425 sysfs_remove_link(&dev->kobj, "bus"); 428 sysfs_remove_link(&dev->kobj, "bus");
426 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 429 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
427 device_remove_attrs(dev->bus, dev); 430 device_remove_attrs(dev->bus, dev);
428 klist_remove(&dev->knode_bus); 431 dev->is_registered = 0;
432 klist_del(&dev->knode_bus);
429 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 433 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
430 device_release_driver(dev); 434 device_release_driver(dev);
431 put_bus(dev->bus); 435 put_bus(dev->bus);