From: Axel Lin Date: Mon, 20 Feb 2012 02:32:16 +0000 (+0800) Subject: regulator: Simplify regulator_bulk_get and regulator_bulk_enable error paths X-Git-Tag: v3.4-rc1~168^2~9 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b29c7690a764b9829b1034f873f97b7bbfa19565;p=karo-tx-linux.git regulator: Simplify regulator_bulk_get and regulator_bulk_enable error paths 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 Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9a143aebb84b..6c845200a530 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -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; }