linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Subject: Re: [PATCH] hwmon: (lm90) Improve error handling
Date: Wed, 27 Jul 2016 10:48:05 +0200	[thread overview]
Message-ID: <20160727104805.3ed87ae5@endymion> (raw)
In-Reply-To: <1469546388-29907-3-git-send-email-linux@roeck-us.net>

Hi Guenter,

On Tue, 26 Jul 2016 08:19:47 -0700, Guenter Roeck wrote:
> Replace devm_add_action() with devm_add_action_or_reset(),
> and check its return value.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/hwmon/lm90.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index 7b3eedf76c62..fa15f7238a28 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -1551,9 +1551,7 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
>  	if (config != data->config_orig) /* Only write if changed */
>  		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
>  
> -	devm_add_action(&client->dev, lm90_restore_conf, data);
> -
> -	return 0;
> +	return devm_add_action_or_reset(&client->dev, lm90_restore_conf, data);
>  }
>  
>  static bool lm90_is_tripped(struct i2c_client *client, u16 *status)
> @@ -1640,7 +1638,9 @@ static int lm90_probe(struct i2c_client *client,
>  		return err;
>  	}
>  
> -	devm_add_action(dev, lm90_regulator_disable, regulator);
> +	err = devm_add_action_or_reset(dev, lm90_regulator_disable, regulator);
> +	if (err)
> +		return err;
>  
>  	data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL);
>  	if (!data)
> @@ -1696,7 +1696,9 @@ static int lm90_probe(struct i2c_client *client,
>  		err = device_create_file(dev, &dev_attr_pec);
>  		if (err)
>  			return err;
> -		devm_add_action(dev, lm90_remove_pec, dev);
> +		err = devm_add_action_or_reset(dev, lm90_remove_pec, dev);
> +		if (err)
> +			return err;
>  	}
>  
>  	hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,

I'm not yet familiar with that API but it looks like the right thing to
do.

Reviewed-by: Jean Delvare <jdelvare@suse.de>

-- 
Jean Delvare
SUSE L3 Support

  reply	other threads:[~2016-07-27  8:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 15:19 [PATCH] hwmon: (ftsteutates) Fix potential memory access error Guenter Roeck
2016-07-26 15:19 ` [PATCH] hwmon: (lm75) Improve error handling Guenter Roeck
2016-07-26 15:19 ` [PATCH] hwmon: (lm90) " Guenter Roeck
2016-07-27  8:48   ` Jean Delvare [this message]
2016-07-26 15:19 ` [PATCH] hwmon: (tmp102) " Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160727104805.3ed87ae5@endymion \
    --to=jdelvare@suse.de \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).