Skip to content

Commit

Permalink
regulator: Simplify regulator_bulk_get and regulator_bulk_enable erro…
Browse files Browse the repository at this point in the history
…r 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 <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Feb 20, 2012
1 parent fde297b commit b29c769
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b29c769

Please sign in to comment.