All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Kunze <thommycheck@gmx.de>,
	Anton Vorontsov <cbouatmailru@gmail.com>
Subject: [PATCH] power_supply: collie_battery: simplify collie_bat_probe error handling
Date: Fri, 26 Aug 2011 11:14:29 +0800	[thread overview]
Message-ID: <1314328469.4571.1.camel@phoenix> (raw)

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




             reply	other threads:[~2011-08-26  3:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26  3:14 Axel Lin [this message]
2011-08-26  7:09 ` [PATCH] power_supply: collie_battery: simplify collie_bat_probe error handling Igor Grinberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314328469.4571.1.camel@phoenix \
    --to=axel.lin@gmail.com \
    --cc=cbouatmailru@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thommycheck@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.