]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
regulator: Simplify regulator_bulk_get and regulator_bulk_enable error paths
authorAxel Lin <axel.lin@gmail.com>
Mon, 20 Feb 2012 02:32:16 +0000 (10:32 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 20 Feb 2012 02:50:21 +0000 (18:50 -0800)
Start unwind from the point the error happens instead of iterating over all
consumers, then unwind code can be simpler.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c

index 9a143aebb84b6cf8cf4ce236fb4485161a88e19e..6c845200a53049dde7eecb75f519b538f16fa550 100644 (file)
@@ -2397,7 +2397,7 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
        return 0;
 
 err:
-       for (i = 0; i < num_consumers && consumers[i].consumer; i++)
+       while (--i >= 0)
                regulator_put(consumers[i].consumer);
 
        return ret;
@@ -2447,12 +2447,9 @@ int regulator_bulk_enable(int num_consumers,
        return 0;
 
 err:
-       for (i = 0; i < num_consumers; i++)
-               if (consumers[i].ret == 0)
-                       regulator_disable(consumers[i].consumer);
-               else
-                       pr_err("Failed to enable %s: %d\n",
-                              consumers[i].supply, consumers[i].ret);
+       pr_err("Failed to enable %s: %d\n", consumers[i].supply, ret);
+       while (--i >= 0)
+               regulator_disable(consumers[i].consumer);
 
        return ret;
 }