diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2008-10-17 11:51:11 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-10-17 11:51:11 -0400 |
commit | d2cac802feae6f0c246a9251eefc482bf5ec0f0f (patch) | |
tree | 21042d9f19d485d8ecba85b21a4c98251791adc3 /drivers | |
parent | 49ae6cc8005f45edadf237089c31885834f2608e (diff) |
hwmon: (lm87) Restore original configuration register on removal
This means that if we have to start the monitor when probed, we also
stop it on removal.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/lm87.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 0fecbfd2ba5b..fa0e3794d9a4 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -199,6 +199,7 @@ struct lm87_data { | |||
199 | unsigned long last_updated; /* In jiffies */ | 199 | unsigned long last_updated; /* In jiffies */ |
200 | 200 | ||
201 | u8 channel; /* register value */ | 201 | u8 channel; /* register value */ |
202 | u8 config; /* original register value */ | ||
202 | 203 | ||
203 | u8 in[8]; /* register value */ | 204 | u8 in[8]; /* register value */ |
204 | u8 in_max[8]; /* register value */ | 205 | u8 in_max[8]; /* register value */ |
@@ -832,6 +833,7 @@ exit_remove: | |||
832 | sysfs_remove_group(&new_client->dev.kobj, &lm87_group); | 833 | sysfs_remove_group(&new_client->dev.kobj, &lm87_group); |
833 | sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt); | 834 | sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt); |
834 | exit_free: | 835 | exit_free: |
836 | lm87_write_value(new_client, LM87_REG_CONFIG, data->config); | ||
835 | kfree(data); | 837 | kfree(data); |
836 | exit: | 838 | exit: |
837 | return err; | 839 | return err; |
@@ -840,12 +842,11 @@ exit: | |||
840 | static void lm87_init_client(struct i2c_client *client) | 842 | static void lm87_init_client(struct i2c_client *client) |
841 | { | 843 | { |
842 | struct lm87_data *data = i2c_get_clientdata(client); | 844 | struct lm87_data *data = i2c_get_clientdata(client); |
843 | u8 config; | ||
844 | 845 | ||
845 | data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); | 846 | data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); |
847 | data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F; | ||
846 | 848 | ||
847 | config = lm87_read_value(client, LM87_REG_CONFIG); | 849 | if (!(data->config & 0x01)) { |
848 | if (!(config & 0x01)) { | ||
849 | int i; | 850 | int i; |
850 | 851 | ||
851 | /* Limits are left uninitialized after power-up */ | 852 | /* Limits are left uninitialized after power-up */ |
@@ -869,9 +870,9 @@ static void lm87_init_client(struct i2c_client *client) | |||
869 | } | 870 | } |
870 | 871 | ||
871 | /* Make sure Start is set and INT#_Clear is clear */ | 872 | /* Make sure Start is set and INT#_Clear is clear */ |
872 | if ((config & 0x09) != 0x01) | 873 | if ((data->config & 0x09) != 0x01) |
873 | lm87_write_value(client, LM87_REG_CONFIG, | 874 | lm87_write_value(client, LM87_REG_CONFIG, |
874 | (config & 0x77) | 0x01); | 875 | (data->config & 0x77) | 0x01); |
875 | } | 876 | } |
876 | 877 | ||
877 | static int lm87_remove(struct i2c_client *client) | 878 | static int lm87_remove(struct i2c_client *client) |
@@ -882,6 +883,7 @@ static int lm87_remove(struct i2c_client *client) | |||
882 | sysfs_remove_group(&client->dev.kobj, &lm87_group); | 883 | sysfs_remove_group(&client->dev.kobj, &lm87_group); |
883 | sysfs_remove_group(&client->dev.kobj, &lm87_group_opt); | 884 | sysfs_remove_group(&client->dev.kobj, &lm87_group_opt); |
884 | 885 | ||
886 | lm87_write_value(client, LM87_REG_CONFIG, data->config); | ||
885 | kfree(data); | 887 | kfree(data); |
886 | return 0; | 888 | return 0; |
887 | } | 889 | } |