public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power_supply: collie_battery: simplify collie_bat_probe error handling
@ 2011-08-26  3:14 Axel Lin
  2011-08-26  7:09 ` Igor Grinberg
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2011-08-26  3:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Kunze, Anton Vorontsov

I think this change is better in readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/power/collie_battery.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/power/collie_battery.c b/drivers/power/collie_battery.c
index 548d263..89d6fcd 100644
--- a/drivers/power/collie_battery.c
+++ b/drivers/power/collie_battery.c
@@ -322,10 +322,8 @@ static int __devinit collie_bat_probe(struct ucb1x00_dev *dev)
 
 	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
 		ret = gpio_request(gpios[i].gpio, gpios[i].name);
-		if (ret) {
-			i--;
+		if (ret)
 			goto err_gpio;
-		}
 
 		if (gpios[i].output)
 			ret = gpio_direction_output(gpios[i].gpio,
@@ -333,8 +331,10 @@ static int __devinit collie_bat_probe(struct ucb1x00_dev *dev)
 		else
 			ret = gpio_direction_input(gpios[i].gpio);
 
-		if (ret)
+		if (ret) {
+			gpio_free(gpios[i].gpio);
 			goto err_gpio;
+		}
 	}
 
 	mutex_init(&collie_bat_main.work_lock);
@@ -363,10 +363,8 @@ err_psy_reg_main:
 
 	/* see comment in collie_bat_remove */
 	cancel_work_sync(&bat_work);
-
-	i--;
 err_gpio:
-	for (; i >= 0; i--)
+	while (--i >= 0)
 		gpio_free(gpios[i].gpio);
 
 	return ret;
-- 
1.7.4.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-26  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-26  3:14 [PATCH] power_supply: collie_battery: simplify collie_bat_probe error handling Axel Lin
2011-08-26  7:09 ` Igor Grinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox