ChangeSet 1.781.21.13, 2002/10/17 23:37:35-07:00, david-b@pacbell.net [PATCH] LDM and driver binding Here's a more complete patch for that driver binding problem. Now (a) when scanning for a driver to handle a new device, scanning stops after the first successful probe not the first successful match; and (b) new drivers get every chance to bind to additional devices, even after the first one succeeds. Please merge. This will help resolve some of the USB flakies in recent kernels. Note that (a) was noticed independently by me and Andries Brouwer, and AFAIK this is the first patch to also fix failure (b) which was uncovered by fixing (a). diff -Nru a/drivers/base/core.c b/drivers/base/core.c --- a/drivers/base/core.c Fri Oct 18 14:43:23 2002 +++ b/drivers/base/core.c Fri Oct 18 14:43:23 2002 @@ -26,7 +26,7 @@ static int probe(struct device * dev, struct device_driver * drv) { dev->driver = drv; - return drv->probe ? drv->probe(dev) : 0; + return drv->probe ? drv->probe(dev) : -ENODEV; } static void attach(struct device * dev) @@ -54,7 +54,7 @@ */ static int found_match(struct device * dev, struct device_driver * drv) { - int error = 0; + int error; if (!(error = probe(dev,get_driver(drv)))) { pr_debug("bound device '%s' to driver '%s'\n", @@ -64,7 +64,8 @@ put_driver(drv); dev->driver = NULL; } - return error; + /* return boolean: did driver bind? */ + return error == 0; } /** @@ -84,6 +85,7 @@ if (drv->bus->match && drv->bus->match(dev,drv)) error = found_match(dev,drv); + /* stop bus_for_each_drv() once a driver binds to the device */ return error; } @@ -113,13 +115,13 @@ static int do_driver_attach(struct device * dev, void * data) { struct device_driver * drv = (struct device_driver *)data; - int error = 0; if (!dev->driver) { if (dev->bus->match && dev->bus->match(dev,drv)) - error = found_match(dev,drv); + found_match(dev,drv); } - return error; + /* continue bus_for_each_dev(), to attach to other devices */ + return 0; } int driver_attach(struct device_driver * drv)