Skip to content

Commit

Permalink
[PATCH] driver core: fix error handling in bus_add_device
Browse files Browse the repository at this point in the history
The error handling in bus_add_device() and device_attach() is simply
non-existing. This patch propagates any error from device_attach to
the upper layers to allow for a proper recovery.

From: Hannes Reinecke <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
hreinecke authored and gregkh committed Jun 20, 2005
1 parent acaefc2 commit ca2b94b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,14 @@ int bus_add_device(struct device * dev)

if (bus) {
pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
device_attach(dev);
error = device_attach(dev);
klist_add_tail(&bus->klist_devices, &dev->knode_bus);
device_add_attrs(bus, dev);
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
if (error >= 0)
error = device_add_attrs(bus, dev);
if (!error) {
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
}
}
return error;
}
Expand Down Expand Up @@ -394,7 +397,7 @@ static int bus_rescan_devices_helper(struct device *dev, void *data)
{
int *count = data;

if (!dev->driver && device_attach(dev))
if (!dev->driver && (device_attach(dev) > 0))
(*count)++;

return 0;
Expand Down
3 changes: 2 additions & 1 deletion drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ static int __device_attach(struct device_driver * drv, void * data)
* driver_probe_device() for each pair. If a compatible
* pair is found, break out and return.
*
* Returns 1 if the device was bound to a driver; 0 otherwise.
* Returns 1 if the device was bound to a driver;
* 0 if no matching device was found; error code otherwise.
*/
int device_attach(struct device * dev)
{
Expand Down

0 comments on commit ca2b94b

Please sign in to comment.