]> err.no Git - linux-2.6/commitdiff
[PATCH] Driver core: Fix up the driver and device iterators to be quieter
authorgregkh@suse.de <gregkh@suse.de>
Thu, 31 Mar 2005 20:53:00 +0000 (12:53 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Jun 2005 22:15:27 +0000 (15:15 -0700)
Also stops looping over the lists when a match is found.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de
drivers/base/dd.c

index 159e0623a681bb75c71ad1b9747b3c706c0a7004..dd2a8a79c121b9455e0bc110a32a490608baeab3 100644 (file)
@@ -88,20 +88,23 @@ static int __device_attach(struct device_driver * drv, void * data)
        int error;
 
        error = driver_probe_device(drv, dev);
-
-       if (error == -ENODEV && error == -ENXIO) {
-               /* Driver matched, but didn't support device
-                * or device not found.
-                * Not an error; keep going.
-                */
-               error = 0;
-       } else {
-               /* driver matched but the probe failed */
-               printk(KERN_WARNING
-                      "%s: probe of %s failed with error %d\n",
-                      drv->name, dev->bus_id, error);
+       if (error) {
+               if ((error == -ENODEV) || (error == -ENXIO)) {
+                       /* Driver matched, but didn't support device
+                        * or device not found.
+                        * Not an error; keep going.
+                        */
+                       error = 0;
+               } else {
+                       /* driver matched but the probe failed */
+                       printk(KERN_WARNING
+                              "%s: probe of %s failed with error %d\n",
+                              drv->name, dev->bus_id, error);
+               }
+               return error;
        }
-       return 0;
+       /* stop looking, this device is attached */
+       return 1;
 }
 
 /**
@@ -137,7 +140,10 @@ static int __driver_attach(struct device * dev, void * data)
                                       drv->name, dev->bus_id, error);
                        } else
                                error = 0;
+                       return error;
                }
+               /* stop looking, this driver is attached */
+               return 1;
        }
        return 0;
 }