aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c11
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/dd.c6
4 files changed, 11 insertions, 13 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index de7e1442ce60..d597f2659b23 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -16,7 +16,7 @@ extern int cpu_dev_init(void);
16extern int attribute_container_init(void); 16extern int attribute_container_init(void);
17 17
18extern int bus_add_device(struct device * dev); 18extern int bus_add_device(struct device * dev);
19extern int bus_attach_device(struct device * dev); 19extern void bus_attach_device(struct device * dev);
20extern void bus_remove_device(struct device * dev); 20extern void bus_remove_device(struct device * dev);
21extern struct bus_type *get_bus(struct bus_type * bus); 21extern struct bus_type *get_bus(struct bus_type * bus);
22extern void put_bus(struct bus_type * bus); 22extern void put_bus(struct bus_type * bus);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 9df2e6dff519..20b6dc8706fa 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -447,7 +447,7 @@ out_put:
447 * - Add device to bus's list of devices. 447 * - Add device to bus's list of devices.
448 * - Try to attach to driver. 448 * - Try to attach to driver.
449 */ 449 */
450int bus_attach_device(struct device * dev) 450void bus_attach_device(struct device * dev)
451{ 451{
452 struct bus_type *bus = dev->bus; 452 struct bus_type *bus = dev->bus;
453 int ret = 0; 453 int ret = 0;
@@ -456,13 +456,12 @@ int bus_attach_device(struct device * dev)
456 dev->is_registered = 1; 456 dev->is_registered = 1;
457 if (bus->drivers_autoprobe) 457 if (bus->drivers_autoprobe)
458 ret = device_attach(dev); 458 ret = device_attach(dev);
459 if (ret >= 0) { 459 WARN_ON(ret < 0);
460 if (ret >= 0)
460 klist_add_tail(&dev->knode_bus, &bus->klist_devices); 461 klist_add_tail(&dev->knode_bus, &bus->klist_devices);
461 ret = 0; 462 else
462 } else
463 dev->is_registered = 0; 463 dev->is_registered = 0;
464 } 464 }
465 return ret;
466} 465}
467 466
468/** 467/**
@@ -669,8 +668,6 @@ static int __must_check bus_rescan_devices_helper(struct device *dev,
669 ret = device_attach(dev); 668 ret = device_attach(dev);
670 if (dev->parent) 669 if (dev->parent)
671 up(&dev->parent->sem); 670 up(&dev->parent->sem);
672 if (ret > 0)
673 ret = 0;
674 } 671 }
675 return ret < 0 ? ret : 0; 672 return ret < 0 ? ret : 0;
676} 673}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index bffb69e4bde2..be6aeb430798 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -677,8 +677,7 @@ int device_add(struct device *dev)
677 goto BusError; 677 goto BusError;
678 if (!dev->uevent_suppress) 678 if (!dev->uevent_suppress)
679 kobject_uevent(&dev->kobj, KOBJ_ADD); 679 kobject_uevent(&dev->kobj, KOBJ_ADD);
680 if ((error = bus_attach_device(dev))) 680 bus_attach_device(dev);
681 goto AttachError;
682 if (parent) 681 if (parent)
683 klist_add_tail(&dev->knode_parent, &parent->klist_children); 682 klist_add_tail(&dev->knode_parent, &parent->klist_children);
684 683
@@ -697,8 +696,6 @@ int device_add(struct device *dev)
697 kfree(class_name); 696 kfree(class_name);
698 put_device(dev); 697 put_device(dev);
699 return error; 698 return error;
700 AttachError:
701 bus_remove_device(dev);
702 BusError: 699 BusError:
703 device_pm_remove(dev); 700 device_pm_remove(dev);
704 PMError: 701 PMError:
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 616b4bbacf1b..18dba8e78da7 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -232,7 +232,7 @@ static int device_probe_drivers(void *data)
232 * 232 *
233 * Returns 1 if the device was bound to a driver; 233 * Returns 1 if the device was bound to a driver;
234 * 0 if no matching device was found or multithreaded probing is done; 234 * 0 if no matching device was found or multithreaded probing is done;
235 * error code otherwise. 235 * -ENODEV if the device is not registered.
236 * 236 *
237 * When called for a USB interface, @dev->parent->sem must be held. 237 * When called for a USB interface, @dev->parent->sem must be held.
238 */ 238 */
@@ -246,6 +246,10 @@ int device_attach(struct device * dev)
246 ret = device_bind_driver(dev); 246 ret = device_bind_driver(dev);
247 if (ret == 0) 247 if (ret == 0)
248 ret = 1; 248 ret = 1;
249 else {
250 dev->driver = NULL;
251 ret = 0;
252 }
249 } else { 253 } else {
250 if (dev->bus->multithread_probe) 254 if (dev->bus->multithread_probe)
251 probe_task = kthread_run(device_probe_drivers, dev, 255 probe_task = kthread_run(device_probe_drivers, dev,