lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 26 Aug 2011 10:09:41 +0300
From:	Igor Grinberg <grinberg@...pulab.co.il>
To:	Axel Lin <axel.lin@...il.com>
CC:	linux-kernel@...r.kernel.org, Thomas Kunze <thommycheck@....de>,
	Anton Vorontsov <cbouatmailru@...il.com>
Subject: Re: [PATCH] power_supply: collie_battery: simplify collie_bat_probe
 error handling

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@...il.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.

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ