aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-10-05 17:03:24 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 15:49:55 -0400
commitf70fa6296c2ec8f541f0a9b406ccc2d9d127d639 (patch)
treef9fd9bbb13a62683c6b41612cfb34fa3894f8676 /drivers
parent952ab431cd36c7ab573f685af8679c3677cbdc29 (diff)
Driver core: Don't ignore error returns from probing
This patch (as797) fixes device_add() in the driver core. It needs to pay attention when the driver for a new device reports an error. At the same time, since bus_remove_device() undoes the effects of both bus_add_device() and bus_attach_device(), it needs to check whether the bus_attach_device step failed. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/bus.c6
-rw-r--r--drivers/base/core.c5
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index d516f7d5f168..d7c5ea246a0b 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -439,8 +439,10 @@ void bus_remove_device(struct device * dev)
439 sysfs_remove_link(&dev->kobj, "bus"); 439 sysfs_remove_link(&dev->kobj, "bus");
440 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 440 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
441 device_remove_attrs(dev->bus, dev); 441 device_remove_attrs(dev->bus, dev);
442 dev->is_registered = 0; 442 if (dev->is_registered) {
443 klist_del(&dev->knode_bus); 443 dev->is_registered = 0;
444 klist_del(&dev->knode_bus);
445 }
444 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 446 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
445 device_release_driver(dev); 447 device_release_driver(dev);
446 put_bus(dev->bus); 448 put_bus(dev->bus);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 41f3dca55cd0..68ad11af22b4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -479,7 +479,8 @@ int device_add(struct device *dev)
479 if ((error = bus_add_device(dev))) 479 if ((error = bus_add_device(dev)))
480 goto BusError; 480 goto BusError;
481 kobject_uevent(&dev->kobj, KOBJ_ADD); 481 kobject_uevent(&dev->kobj, KOBJ_ADD);
482 bus_attach_device(dev); 482 if ((error = bus_attach_device(dev)))
483 goto AttachError;
483 if (parent) 484 if (parent)
484 klist_add_tail(&dev->knode_parent, &parent->klist_children); 485 klist_add_tail(&dev->knode_parent, &parent->klist_children);
485 486
@@ -498,6 +499,8 @@ int device_add(struct device *dev)
498 kfree(class_name); 499 kfree(class_name);
499 put_device(dev); 500 put_device(dev);
500 return error; 501 return error;
502 AttachError:
503 bus_remove_device(dev);
501 BusError: 504 BusError:
502 device_pm_remove(dev); 505 device_pm_remove(dev);
503 PMError: 506 PMError: