diff options
author | Jean Delvare <khali@linux-fr.org> | 2012-07-26 22:18:43 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-27 13:59:22 -0700 |
commit | 5953e2761be088f66fd930dfbf6b36a5a41d82a3 (patch) | |
tree | 39fb8d4388a10099bbda30c45ab8352058b152dd /drivers/hwmon/jc42.c | |
parent | 2ccc8731e5054058d5fb990744b4f72a79018d34 (diff) | |
download | linux-stable-5953e2761be088f66fd930dfbf6b36a5a41d82a3.tar.gz linux-stable-5953e2761be088f66fd930dfbf6b36a5a41d82a3.tar.bz2 linux-stable-5953e2761be088f66fd930dfbf6b36a5a41d82a3.zip |
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.c | 13 |
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) struct jc42_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &jc42_group); - if (data->config != data->orig_config) - i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, - data->orig_config); + + /* Restore original configuration except hysteresis */ + if ((data->config & ~JC42_CFG_HYST_MASK) != + (data->orig_config & ~JC42_CFG_HYST_MASK)) { + int config; + + config = (data->orig_config & ~JC42_CFG_HYST_MASK) + | (data->config & JC42_CFG_HYST_MASK); + i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, config); + } return 0; } |