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: <20240328142038.33ad68bc@jic23-huawei>
Date: Thu, 28 Mar 2024 14:20:38 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Jonathan Corbet <corbet@....net>, Liam Girdwood <lgirdwood@...il.com>,
 Mark Brown <broonie@...nel.org>, Jean Delvare <jdelvare@...e.com>, Guenter
 Roeck <linux@...ck-us.net>, Support Opensource
 <support.opensource@...semi.com>, Cosmin Tanislav
 <cosmin.tanislav@...log.com>, Lars-Peter Clausen <lars@...afoo.de>, Michael
 Hennerich <Michael.Hennerich@...log.com>, Antoniu Miclaus
 <antoniu.miclaus@...log.com>, Greg Kroah-Hartman
 <gregkh@...uxfoundation.org>, Dmitry Torokhov <dmitry.torokhov@...il.com>,
 linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-hwmon@...r.kernel.org, linux-iio@...r.kernel.org,
 linux-staging@...ts.linux.dev, linux-input@...r.kernel.org
Subject: Re: [PATCH RFC 3/7] hwmon: (da9052) Use
 devm_regulator_get_enable_get_voltage()

On Wed, 27 Mar 2024 18:18:52 -0500
David Lechner <dlechner@...libre.com> wrote:

> We can reduce boilerplate code by using
> devm_regulator_get_enable_get_voltage().
> 
> Signed-off-by: David Lechner <dlechner@...libre.com>

A few comments inline, but nothing substantial.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> ---
>  drivers/hwmon/da9052-hwmon.c | 33 +++++++--------------------------
>  1 file changed, 7 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
> index 2bd7ae8100d7..70e7bc72e980 100644
> --- a/drivers/hwmon/da9052-hwmon.c
> +++ b/drivers/hwmon/da9052-hwmon.c
> @@ -26,7 +26,6 @@ struct da9052_hwmon {
>  	struct mutex		hwmon_lock;
>  	bool			tsi_as_adc;
>  	int			tsiref_mv;
> -	struct regulator	*tsiref;
>  	struct completion	tsidone;
>  };
>  
> @@ -414,32 +413,19 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
>  		device_property_read_bool(pdev->dev.parent, "dlg,tsi-as-adc");
>  
>  	if (hwmon->tsi_as_adc) {
> -		hwmon->tsiref = devm_regulator_get(pdev->dev.parent, "tsiref");
> -		if (IS_ERR(hwmon->tsiref)) {
> -			err = PTR_ERR(hwmon->tsiref);
> -			dev_err(&pdev->dev, "failed to get tsiref: %d", err);
> +		err = devm_regulator_get_enable_get_voltage(pdev->dev.parent,
> +							    "tsiref");
> +		if (err < 0)
>  			return err;
> -		}
> -
> -		err = regulator_enable(hwmon->tsiref);
> -		if (err)
> -			return err;
> -
> -		hwmon->tsiref_mv = regulator_get_voltage(hwmon->tsiref);
> -		if (hwmon->tsiref_mv < 0) {
> -			err = hwmon->tsiref_mv;
> -			goto exit_regulator;
> -		}
>  
>  		/* convert from microvolt (DT) to millivolt (hwmon) */
> -		hwmon->tsiref_mv /= 1000;
> +		hwmon->tsiref_mv = err / 1000;
>

Using a variable called err for a good value is a bit ugly but fair enough if that
is precedence in this driver.

>  }
> @@ -483,10 +466,8 @@ static void da9052_hwmon_remove(struct platform_device *pdev)
>  {
>  	struct da9052_hwmon *hwmon = platform_get_drvdata(pdev);
>  
> -	if (hwmon->tsi_as_adc) {
> +	if (hwmon->tsi_as_adc)
>  		da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon);
Superficially looks like devm_da9052_request_irq could be added that
uses devm_request_threaded_irq() to allow dropping this remaining handling.

Thanks,

Jonathan

> -		regulator_disable(hwmon->tsiref);
> -	}
>  }
>  
>  static struct platform_driver da9052_hwmon_driver = {
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ