All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: (lm90) Restore original configuration if probe function fails
@ 2012-02-27 20:59 Guenter Roeck
  2012-03-01 16:14 ` Guenter Roeck
  2012-03-02  7:47 ` Jean Delvare
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2012-02-27 20:59 UTC (permalink / raw)
  To: lm-sensors

The lm90 driver restores the original chip configuration in its exit function.
However, the chip configuration is not restored if the probe function fails.
Restore it there as well.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/lm90.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index d2dd5f9..178de29 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1313,6 +1313,15 @@ static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data)
 	sysfs_remove_group(&dev->kobj, &lm90_group);
 }
 
+static void lm90_restore_conf(struct i2c_client *client, struct lm90_data *data)
+{
+	/* Restore initial configuration */
+	i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
+				  data->convrate_orig);
+	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
+				  data->config_orig);
+}
+
 static void lm90_init_client(struct i2c_client *client)
 {
 	u8 config, convrate;
@@ -1399,7 +1408,7 @@ static int lm90_probe(struct i2c_client *client,
 	/* Register sysfs hooks */
 	err = sysfs_create_group(&dev->kobj, &lm90_group);
 	if (err)
-		goto exit_free;
+		goto exit_restore;
 	if (client->flags & I2C_CLIENT_PEC) {
 		err = device_create_file(dev, &dev_attr_pec);
 		if (err)
@@ -1438,7 +1447,8 @@ static int lm90_probe(struct i2c_client *client,
 
 exit_remove_files:
 	lm90_remove_files(client, data);
-exit_free:
+exit_restore:
+	lm90_restore_conf(client, data);
 	kfree(data);
 exit:
 	return err;
@@ -1450,12 +1460,7 @@ static int lm90_remove(struct i2c_client *client)
 
 	hwmon_device_unregister(data->hwmon_dev);
 	lm90_remove_files(client, data);
-
-	/* Restore initial configuration */
-	i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
-				  data->convrate_orig);
-	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
-				  data->config_orig);
+	lm90_restore_conf(client, data);
 
 	kfree(data);
 	return 0;
-- 
1.7.5.4


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (lm90) Restore original configuration if probe function fails
  2012-02-27 20:59 [lm-sensors] [PATCH] hwmon: (lm90) Restore original configuration if probe function fails Guenter Roeck
@ 2012-03-01 16:14 ` Guenter Roeck
  2012-03-02  7:47 ` Jean Delvare
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2012-03-01 16:14 UTC (permalink / raw)
  To: lm-sensors

Hi Jean,

On Mon, 2012-02-27 at 15:59 -0500, Guenter Roeck wrote:
> The lm90 driver restores the original chip configuration in its exit function.
> However, the chip configuration is not restored if the probe function fails.
> Restore it there as well.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Any comments on this one ? I don't want to submit it upstream without
your approval / Ack.

Thanks,
Guenter

> ---
>  drivers/hwmon/lm90.c |   21 +++++++++++++--------
>  1 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index d2dd5f9..178de29 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -1313,6 +1313,15 @@ static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data)
>  	sysfs_remove_group(&dev->kobj, &lm90_group);
>  }
>  
> +static void lm90_restore_conf(struct i2c_client *client, struct lm90_data *data)
> +{
> +	/* Restore initial configuration */
> +	i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
> +				  data->convrate_orig);
> +	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
> +				  data->config_orig);
> +}
> +
>  static void lm90_init_client(struct i2c_client *client)
>  {
>  	u8 config, convrate;
> @@ -1399,7 +1408,7 @@ static int lm90_probe(struct i2c_client *client,
>  	/* Register sysfs hooks */
>  	err = sysfs_create_group(&dev->kobj, &lm90_group);
>  	if (err)
> -		goto exit_free;
> +		goto exit_restore;
>  	if (client->flags & I2C_CLIENT_PEC) {
>  		err = device_create_file(dev, &dev_attr_pec);
>  		if (err)
> @@ -1438,7 +1447,8 @@ static int lm90_probe(struct i2c_client *client,
>  
>  exit_remove_files:
>  	lm90_remove_files(client, data);
> -exit_free:
> +exit_restore:
> +	lm90_restore_conf(client, data);
>  	kfree(data);
>  exit:
>  	return err;
> @@ -1450,12 +1460,7 @@ static int lm90_remove(struct i2c_client *client)
>  
>  	hwmon_device_unregister(data->hwmon_dev);
>  	lm90_remove_files(client, data);
> -
> -	/* Restore initial configuration */
> -	i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
> -				  data->convrate_orig);
> -	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
> -				  data->config_orig);
> +	lm90_restore_conf(client, data);
>  
>  	kfree(data);
>  	return 0;



_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (lm90) Restore original configuration if probe function fails
  2012-02-27 20:59 [lm-sensors] [PATCH] hwmon: (lm90) Restore original configuration if probe function fails Guenter Roeck
  2012-03-01 16:14 ` Guenter Roeck
@ 2012-03-02  7:47 ` Jean Delvare
  1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2012-03-02  7:47 UTC (permalink / raw)
  To: lm-sensors

On Mon, 27 Feb 2012 12:59:47 -0800, Guenter Roeck wrote:
> The lm90 driver restores the original chip configuration in its exit function.
> However, the chip configuration is not restored if the probe function fails.
> Restore it there as well.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/hwmon/lm90.c |   21 +++++++++++++--------
>  1 files changed, 13 insertions(+), 8 deletions(-)
> (...)

Applied, thanks.

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-02  7:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27 20:59 [lm-sensors] [PATCH] hwmon: (lm90) Restore original configuration if probe function fails Guenter Roeck
2012-03-01 16:14 ` Guenter Roeck
2012-03-02  7:47 ` Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.