linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: Simplify regulator_bulk_get and regulator_bulk_enable error paths
@ 2012-02-20  2:32 Axel Lin
  0 siblings, 0 replies; only message in thread
From: Axel Lin @ 2012-02-20  2:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood

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>
---
 drivers/regulator/core.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index fecda41..37a84df 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2451,7 +2451,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;
@@ -2547,12 +2547,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;
 }
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-20  2:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20  2:32 [PATCH] regulator: Simplify regulator_bulk_get and regulator_bulk_enable error paths Axel Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).