aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/jc42.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2012-07-26 16:18:43 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-27 16:59:22 -0400
commit5953e2761be088f66fd930dfbf6b36a5a41d82a3 (patch)
tree39fb8d4388a10099bbda30c45ab8352058b152dd /drivers/hwmon/jc42.c
parent2ccc8731e5054058d5fb990744b4f72a79018d34 (diff)
hwmon: (jc42) Don't reset hysteresis on device removal
Restoring the configuration register on device removal has the side effect of also resetting the hysteresis value. This is inconsistent as the other limits are not reset, only hysteresis. So, following the principle of least surprise, preserve the hysteresis value when restoring the configuration register. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/jc42.c')
-rw-r--r--drivers/hwmon/jc42.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
index 44f189ed414a..e21e43c13156 100644
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -534,9 +534,16 @@ static int jc42_remove(struct i2c_client *client)
534 struct jc42_data *data = i2c_get_clientdata(client); 534 struct jc42_data *data = i2c_get_clientdata(client);
535 hwmon_device_unregister(data->hwmon_dev); 535 hwmon_device_unregister(data->hwmon_dev);
536 sysfs_remove_group(&client->dev.kobj, &jc42_group); 536 sysfs_remove_group(&client->dev.kobj, &jc42_group);
537 if (data->config != data->orig_config) 537
538 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, 538 /* Restore original configuration except hysteresis */
539 data->orig_config); 539 if ((data->config & ~JC42_CFG_HYST_MASK) !=
540 (data->orig_config & ~JC42_CFG_HYST_MASK)) {
541 int config;
542
543 config = (data->orig_config & ~JC42_CFG_HYST_MASK)
544 | (data->config & JC42_CFG_HYST_MASK);
545 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, config);
546 }
540 return 0; 547 return 0;
541} 548}
542 549