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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191019090749.ps27yjfebzscw2pk@earth.universe>
Date:   Sat, 19 Oct 2019 11:07:49 +0200
From:   Sebastian Reichel <sre@...nel.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Daniel Mack <daniel@...que.org>,
        Haojian Zhuang <haojian.zhuang@...il.com>,
        Robert Jarzmik <robert.jarzmik@...e.fr>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Linus Walleij <linus.walleij@...aro.org>,
        linux-pm@...r.kernel.org
Subject: Re: [PATCH 39/46] power: tosa: simplify probe function

Hi Arnd,

On Fri, Oct 18, 2019 at 05:41:54PM +0200, Arnd Bergmann wrote:
> We have three power supplies that need similar initialization.
> As a preparation for the gpio lookup table conversion, split
> out the initialization into a separate function.
> 
> Cc: Sebastian Reichel <sre@...nel.org>
> Cc: linux-pm@...r.kernel.org
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---

Assuming, that the whole series goes through ARM:

Reviewed-by: Sebastian Reichel <sre@...nel.org>
Acked-by: Sebastian Reichel <sre@...nel.org>

If the series doesn't make it into 5.5, I can also apply
this cleanup patch.

-- Sebastian

>  drivers/power/supply/tosa_battery.c | 50 ++++++++++++++---------------
>  1 file changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/power/supply/tosa_battery.c b/drivers/power/supply/tosa_battery.c
> index 32cc31cd4761..b26b0eca33e1 100644
> --- a/drivers/power/supply/tosa_battery.c
> +++ b/drivers/power/supply/tosa_battery.c
> @@ -343,12 +343,24 @@ static int tosa_bat_resume(struct platform_device *dev)
>  #define tosa_bat_resume NULL
>  #endif
>  
> +static int tosa_power_supply_register(struct device *dev,
> +			struct tosa_bat *bat,
> +			const struct power_supply_desc *desc)
> +{
> +	struct power_supply_config cfg = {
> +		.drv_data = bat,
> +	};
> +
> +	mutex_init(&bat->work_lock);
> +	bat->psy = power_supply_register(dev, desc, &cfg);
> +
> +	return PTR_ERR_OR_ZERO(bat->psy);
> +}
> +
> +
>  static int tosa_bat_probe(struct platform_device *dev)
>  {
>  	int ret;
> -	struct power_supply_config main_psy_cfg = {},
> -				   jacket_psy_cfg = {},
> -				   bu_psy_cfg = {};
>  
>  	if (!machine_is_tosa())
>  		return -ENODEV;
> @@ -357,36 +369,22 @@ static int tosa_bat_probe(struct platform_device *dev)
>  	if (ret)
>  		return ret;
>  
> -	mutex_init(&tosa_bat_main.work_lock);
> -	mutex_init(&tosa_bat_jacket.work_lock);
> -
>  	INIT_WORK(&bat_work, tosa_bat_work);
>  
> -	main_psy_cfg.drv_data = &tosa_bat_main;
> -	tosa_bat_main.psy = power_supply_register(&dev->dev,
> -						  &tosa_bat_main_desc,
> -						  &main_psy_cfg);
> -	if (IS_ERR(tosa_bat_main.psy)) {
> -		ret = PTR_ERR(tosa_bat_main.psy);
> +	ret = tosa_power_supply_register(&dev->dev, &tosa_bat_main,
> +					 &tosa_bat_main_desc);
> +	if (ret)
>  		goto err_psy_reg_main;
> -	}
>  
> -	jacket_psy_cfg.drv_data = &tosa_bat_jacket;
> -	tosa_bat_jacket.psy = power_supply_register(&dev->dev,
> -						    &tosa_bat_jacket_desc,
> -						    &jacket_psy_cfg);
> -	if (IS_ERR(tosa_bat_jacket.psy)) {
> -		ret = PTR_ERR(tosa_bat_jacket.psy);
> +	ret = tosa_power_supply_register(&dev->dev, &tosa_bat_jacket,
> +					 &tosa_bat_jacket_desc);
> +	if (ret)
>  		goto err_psy_reg_jacket;
> -	}
>  
> -	bu_psy_cfg.drv_data = &tosa_bat_bu;
> -	tosa_bat_bu.psy = power_supply_register(&dev->dev, &tosa_bat_bu_desc,
> -						&bu_psy_cfg);
> -	if (IS_ERR(tosa_bat_bu.psy)) {
> -		ret = PTR_ERR(tosa_bat_bu.psy);
> +	ret = tosa_power_supply_register(&dev->dev, &tosa_bat_bu,
> +					 &tosa_bat_bu_desc);
> +	if (ret)
>  		goto err_psy_reg_bu;
> -	}
>  
>  	ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG),
>  				tosa_bat_gpio_isr,
> -- 
> 2.20.0
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ