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: <2c78b4e7-f481-e29d-1196-a1b73d232635@roeck-us.net>
Date:   Wed, 10 Aug 2022 05:52:57 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Matti Vaittinen <mazziesaccount@...il.com>,
        matti.vaittinen@...rohmeurope.com
Cc:     Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 6/7] hwmon: lm90: simplify using
 devm_regulator_get_enable()

On 8/10/22 04:32, 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().
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@...il.com>

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

> ---
>   drivers/hwmon/lm90.c | 21 ++-------------------
>   1 file changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index 3820f0e61510..2ab561ec367c 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -1848,12 +1848,6 @@ static void lm90_remove_pec(void *dev)
>   	device_remove_file(dev, &dev_attr_pec);
>   }
>   
> -static void lm90_regulator_disable(void *regulator)
> -{
> -	regulator_disable(regulator);
> -}
> -
> -
>   static const struct hwmon_ops lm90_ops = {
>   	.is_visible = lm90_is_visible,
>   	.read = lm90_read,
> @@ -1865,24 +1859,13 @@ static int lm90_probe(struct i2c_client *client)
>   	struct device *dev = &client->dev;
>   	struct i2c_adapter *adapter = client->adapter;
>   	struct hwmon_channel_info *info;
> -	struct regulator *regulator;
>   	struct device *hwmon_dev;
>   	struct lm90_data *data;
>   	int err;
>   
> -	regulator = devm_regulator_get(dev, "vcc");
> -	if (IS_ERR(regulator))
> -		return PTR_ERR(regulator);
> -
> -	err = regulator_enable(regulator);
> -	if (err < 0) {
> -		dev_err(dev, "Failed to enable regulator: %d\n", err);
> -		return err;
> -	}
> -
> -	err = devm_add_action_or_reset(dev, lm90_regulator_disable, regulator);
> +	err = devm_regulator_get_enable(dev, "vcc");
>   	if (err)
> -		return err;
> +		return dev_err_probe(dev, err, "Failed to enable regulator\n");
>   
>   	data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL);
>   	if (!data)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ