public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Igor Grinberg <grinberg@compulab.co.il>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel@vger.kernel.org, Thomas Kunze <thommycheck@gmx.de>,
	Anton Vorontsov <cbouatmailru@gmail.com>
Subject: Re: [PATCH] power_supply: collie_battery: simplify collie_bat_probe error handling
Date: Fri, 26 Aug 2011 10:09:41 +0300	[thread overview]
Message-ID: <4E5746B5.5090408@compulab.co.il> (raw)
In-Reply-To: <1314328469.4571.1.camel@phoenix>

Mailer problem, sorry, sending once again...


Hi Axel,



On 08/26/11 06:14, Axel Lin wrote:
> I think this change is better in readability.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---

May be just convert it to use struct gpio and gpio_<request|free>_array() calls?
Because right now it uses the same concept, but really awkward...

>  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;

-- 
Regards,
Igor.


      reply	other threads:[~2011-08-26  7:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=4E5746B5.5090408@compulab.co.il \
    --to=grinberg@compulab.co.il \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox