aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c23
-rw-r--r--drivers/base/core.c2
3 files changed, 12 insertions, 15 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index b528145a078f..1e52c125f437 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -104,7 +104,7 @@ extern int system_bus_init(void);
104extern int cpu_dev_init(void); 104extern int cpu_dev_init(void);
105 105
106extern int bus_add_device(struct device *dev); 106extern int bus_add_device(struct device *dev);
107extern void bus_attach_device(struct device *dev); 107extern void bus_probe_device(struct device *dev);
108extern void bus_remove_device(struct device *dev); 108extern void bus_remove_device(struct device *dev);
109 109
110extern int bus_add_driver(struct device_driver *drv); 110extern int bus_add_driver(struct device_driver *drv);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 4b04a15146d7..973bf2ad4e0d 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -459,8 +459,9 @@ static inline void remove_deprecated_bus_links(struct device *dev) { }
459 * bus_add_device - add device to bus 459 * bus_add_device - add device to bus
460 * @dev: device being added 460 * @dev: device being added
461 * 461 *
462 * - Add device's bus attributes.
463 * - Create links to device's bus.
462 * - Add the device to its bus's list of devices. 464 * - Add the device to its bus's list of devices.
463 * - Create link to device's bus.
464 */ 465 */
465int bus_add_device(struct device *dev) 466int bus_add_device(struct device *dev)
466{ 467{
@@ -483,6 +484,7 @@ int bus_add_device(struct device *dev)
483 error = make_deprecated_bus_links(dev); 484 error = make_deprecated_bus_links(dev);
484 if (error) 485 if (error)
485 goto out_deprecated; 486 goto out_deprecated;
487 klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices);
486 } 488 }
487 return 0; 489 return 0;
488 490
@@ -498,24 +500,19 @@ out_put:
498} 500}
499 501
500/** 502/**
501 * bus_attach_device - add device to bus 503 * bus_probe_device - probe drivers for a new device
502 * @dev: device tried to attach to a driver 504 * @dev: device to probe
503 * 505 *
504 * - Add device to bus's list of devices. 506 * - Automatically probe for a driver if the bus allows it.
505 * - Try to attach to driver.
506 */ 507 */
507void bus_attach_device(struct device *dev) 508void bus_probe_device(struct device *dev)
508{ 509{
509 struct bus_type *bus = dev->bus; 510 struct bus_type *bus = dev->bus;
510 int ret = 0; 511 int ret;
511 512
512 if (bus) { 513 if (bus && bus->p->drivers_autoprobe) {
513 if (bus->p->drivers_autoprobe) 514 ret = device_attach(dev);
514 ret = device_attach(dev);
515 WARN_ON(ret < 0); 515 WARN_ON(ret < 0);
516 if (ret >= 0)
517 klist_add_tail(&dev->p->knode_bus,
518 &bus->p->klist_devices);
519 } 516 }
520} 517}
521 518
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7ecb1938e590..c34774d0b9d3 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -945,7 +945,7 @@ int device_add(struct device *dev)
945 BUS_NOTIFY_ADD_DEVICE, dev); 945 BUS_NOTIFY_ADD_DEVICE, dev);
946 946
947 kobject_uevent(&dev->kobj, KOBJ_ADD); 947 kobject_uevent(&dev->kobj, KOBJ_ADD);
948 bus_attach_device(dev); 948 bus_probe_device(dev);
949 if (parent) 949 if (parent)
950 klist_add_tail(&dev->p->knode_parent, 950 klist_add_tail(&dev->p->knode_parent,
951 &parent->p->klist_children); 951 &parent->p->klist_children);