aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2006-04-04 14:42:26 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-21 15:40:47 -0400
commit53877d06d53a412d901bb323f080296c363d8b51 (patch)
treeceffbd4dd9342e1742bf59165880888f7f961f33 /drivers/base
parent27c0ff868f2ad3c9732ce45abbb8dd7e1723931f (diff)
[PATCH] Driver core: bus device event delay
split bus_add_device() and send device uevents after sysfs population Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/base.h1
-rw-r--r--drivers/base/bus.c22
-rw-r--r--drivers/base/core.c3
3 files changed, 21 insertions, 5 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 5735b38582d0..bbbc2acd921c 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -11,6 +11,7 @@ extern int cpu_dev_init(void);
11extern int attribute_container_init(void); 11extern int attribute_container_init(void);
12 12
13extern int bus_add_device(struct device * dev); 13extern int bus_add_device(struct device * dev);
14extern void bus_attach_device(struct device * dev);
14extern void bus_remove_device(struct device * dev); 15extern void bus_remove_device(struct device * dev);
15 16
16extern int bus_add_driver(struct device_driver *); 17extern int bus_add_driver(struct device_driver *);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 76656acd00d4..b27a6067e5a4 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 */
368int bus_add_device(struct device * dev) 367int bus_add_device(struct device * dev)
369{ 368{
@@ -372,8 +371,6 @@ 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);
@@ -384,6 +381,22 @@ int bus_add_device(struct device * dev)
384} 381}
385 382
386/** 383/**
384 * bus_attach_device - add device to bus
385 * @dev: device tried to attach to a driver
386 *
387 * - Try to attach to driver.
388 */
389void bus_attach_device(struct device * dev)
390{
391 struct bus_type * bus = dev->bus;
392
393 if (bus) {
394 device_attach(dev);
395 klist_add_tail(&dev->knode_bus, &bus->klist_devices);
396 }
397}
398
399/**
387 * bus_remove_device - remove device from bus 400 * bus_remove_device - remove device from bus
388 * @dev: device to be removed 401 * @dev: device to be removed
389 * 402 *
@@ -733,6 +746,7 @@ EXPORT_SYMBOL_GPL(bus_find_device);
733EXPORT_SYMBOL_GPL(bus_for_each_drv); 746EXPORT_SYMBOL_GPL(bus_for_each_drv);
734 747
735EXPORT_SYMBOL_GPL(bus_add_device); 748EXPORT_SYMBOL_GPL(bus_add_device);
749EXPORT_SYMBOL_GPL(bus_attach_device);
736EXPORT_SYMBOL_GPL(bus_remove_device); 750EXPORT_SYMBOL_GPL(bus_remove_device);
737EXPORT_SYMBOL_GPL(bus_register); 751EXPORT_SYMBOL_GPL(bus_register);
738EXPORT_SYMBOL_GPL(bus_unregister); 752EXPORT_SYMBOL_GPL(bus_unregister);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6b355bd7816d..d5e15a03584e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -274,11 +274,12 @@ int device_add(struct device *dev)
274 dev->uevent_attr.store = store_uevent; 274 dev->uevent_attr.store = store_uevent;
275 device_create_file(dev, &dev->uevent_attr); 275 device_create_file(dev, &dev->uevent_attr);
276 276
277 kobject_uevent(&dev->kobj, KOBJ_ADD);
278 if ((error = device_pm_add(dev))) 277 if ((error = device_pm_add(dev)))
279 goto PMError; 278 goto PMError;
280 if ((error = bus_add_device(dev))) 279 if ((error = bus_add_device(dev)))
281 goto BusError; 280 goto BusError;
281 kobject_uevent(&dev->kobj, KOBJ_ADD);
282 bus_attach_device(dev);
282 if (parent) 283 if (parent)
283 klist_add_tail(&dev->knode_parent, &parent->klist_children); 284 klist_add_tail(&dev->knode_parent, &parent->klist_children);
284 285