[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1314328469.4571.1.camel@phoenix>
Date: Fri, 26 Aug 2011 11:14:29 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Thomas Kunze <thommycheck@....de>,
Anton Vorontsov <cbouatmailru@...il.com>
Subject: [PATCH] power_supply: collie_battery: simplify collie_bat_probe
error handling
I think this change is better in readability.
Signed-off-by: Axel Lin <axel.lin@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists