]> git.neil.brown.name Git - history.git/commitdiff
[PNP] minor resource management fixes
authorAdam Belay <ambx1@neo.rr.com>
Wed, 14 Apr 2004 04:28:04 +0000 (04:28 +0000)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 14 Apr 2004 04:28:04 +0000 (04:28 +0000)
This patch fixes a bug in pnp_auto_config_dev in which it wouldn't always report
allocation failures.  It also corrects the return codes.

drivers/pnp/manager.c

index bd344233e5e872a308ebcc3df96614a344fe74b4..b31a33a875b56c2ea0dc86aa85eab2a4dcbe781e 100644 (file)
@@ -452,23 +452,19 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
 
        if (!dev->dependent) {
                if (pnp_assign_resources(dev, 0))
-                       return 1;
-               else
                        return 0;
+       } else {
+               dep = dev->dependent;
+               do {
+                       if (pnp_assign_resources(dev, i))
+                               return 0;
+                       dep = dep->next;
+                       i++;
+               } while (dep);
        }
 
-       dep = dev->dependent;
-       do {
-               if (pnp_assign_resources(dev, i))
-                       return 1;
-
-               /* if this dependent resource failed, try the next one */
-               dep = dep->next;
-               i++;
-       } while (dep);
-
        pnp_err("Unable to assign resources to device %s.", dev->dev.bus_id);
-       return 0;
+       return -EBUSY;
 }
 
 /**
@@ -486,7 +482,7 @@ int pnp_activate_dev(struct pnp_dev *dev)
        }
 
        /* ensure resources are allocated */
-       if (!pnp_auto_config_dev(dev))
+       if (pnp_auto_config_dev(dev))
                return -EBUSY;
 
        if (!pnp_can_write(dev)) {