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]
Date:   Fri, 19 Aug 2022 12:36:33 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Matti Vaittinen <mazziesaccount@...il.com>
Cc:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Michael Hennerich <Michael.Hennerich@...log.com>,
        Jean Delvare <jdelvare@...e.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 05/14] hwmon: adm1177: simplify using
 devm_regulator_get_enable()

On Fri, Aug 19, 2022 at 10:18:46PM +0300, Matti Vaittinen wrote:
> Drop open-coded pattern: 'devm_regulator_get(), regulator_enable(),
> add_action_or_reset(regulator_disable)' and use the
> devm_regulator_get_enable() and drop the pointer to the regulator.
> This simplifies code and makes it less tempting to add manual control
> for the regulator which is also controlled by devm.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@...il.com>

Acked-by: Guenter Roeck <linux@...ck-us.net>

> 
> ---
> v2 => v3:
> New patch
> ---
>  drivers/hwmon/adm1177.c | 27 +++------------------------
>  1 file changed, 3 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/hwmon/adm1177.c b/drivers/hwmon/adm1177.c
> index 0c5dbc5e33b4..be17a26a84f1 100644
> --- a/drivers/hwmon/adm1177.c
> +++ b/drivers/hwmon/adm1177.c
> @@ -26,14 +26,12 @@
>  /**
>   * struct adm1177_state - driver instance specific data
>   * @client:		pointer to i2c client
> - * @reg:		regulator info for the power supply of the device
>   * @r_sense_uohm:	current sense resistor value
>   * @alert_threshold_ua:	current limit for shutdown
>   * @vrange_high:	internal voltage divider
>   */
>  struct adm1177_state {
>  	struct i2c_client	*client;
> -	struct regulator	*reg;
>  	u32			r_sense_uohm;
>  	u32			alert_threshold_ua;
>  	bool			vrange_high;
> @@ -189,13 +187,6 @@ static const struct hwmon_chip_info adm1177_chip_info = {
>  	.info = adm1177_info,
>  };
>  
> -static void adm1177_remove(void *data)
> -{
> -	struct adm1177_state *st = data;
> -
> -	regulator_disable(st->reg);
> -}
> -
>  static int adm1177_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
> @@ -210,21 +201,9 @@ static int adm1177_probe(struct i2c_client *client)
>  
>  	st->client = client;
>  
> -	st->reg = devm_regulator_get_optional(&client->dev, "vref");
> -	if (IS_ERR(st->reg)) {
> -		if (PTR_ERR(st->reg) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		st->reg = NULL;
> -	} else {
> -		ret = regulator_enable(st->reg);
> -		if (ret)
> -			return ret;
> -		ret = devm_add_action_or_reset(&client->dev, adm1177_remove,
> -					       st);
> -		if (ret)
> -			return ret;
> -	}
> +	ret = devm_regulator_get_enable_optional(&client->dev, "vref");
> +	if (ret == -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
>  
>  	if (device_property_read_u32(dev, "shunt-resistor-micro-ohms",
>  				     &st->r_sense_uohm))
> -- 
> 2.37.1
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ