Skip to contentSkip to conversation

regulator: Simplify regulator_bulk_get and regulator_bulk_enable error paths

PATCH New Axel Lin 1 participant 1 message Feb 20, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/regulator/core.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
drivers/regulator/core.c +4 -7
index fecda41..37a84df 100644
@@ -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;
 }
Signature · 1 line
1.7.5.4