aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-03-05 16:17:14 -0500
committerJean Delvare <khali@linux-fr.org>2010-03-05 16:17:14 -0500
commit95238364167edaf93ce2890e5f55326b63194851 (patch)
tree21a1c398b9102c74d38a61d22d34089e5697ccd1 /drivers/hwmon
parent6771ea1fff988651593f78c122bc02e80f5100a0 (diff)
hwmon: (lm90) Restore configuration on exit
Restore the chip configuration when unloading the driver. This ensures we don't leave the chip running if it was initially stopped. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm90.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index ddf617f3a71..4cbbf1563de 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware 2 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring 3 * monitoring
4 * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> 4 * Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
5 * 5 *
6 * Based on the lm83 driver. The LM90 is a sensor chip made by National 6 * Based on the lm83 driver. The LM90 is a sensor chip made by National
7 * Semiconductor. It reports up to two temperatures (its own plus up to 7 * Semiconductor. It reports up to two temperatures (its own plus up to
@@ -203,6 +203,8 @@ struct lm90_data {
203 int kind; 203 int kind;
204 int flags; 204 int flags;
205 205
206 u8 config_orig; /* Original configuration register value */
207
206 /* registers values */ 208 /* registers values */
207 s8 temp8[4]; /* 0: local low limit 209 s8 temp8[4]; /* 0: local low limit
208 1: local high limit 210 1: local high limit
@@ -840,7 +842,7 @@ exit:
840 842
841static void lm90_init_client(struct i2c_client *client) 843static void lm90_init_client(struct i2c_client *client)
842{ 844{
843 u8 config, config_orig; 845 u8 config;
844 struct lm90_data *data = i2c_get_clientdata(client); 846 struct lm90_data *data = i2c_get_clientdata(client);
845 847
846 /* 848 /*
@@ -852,7 +854,7 @@ static void lm90_init_client(struct i2c_client *client)
852 dev_warn(&client->dev, "Initialization failed!\n"); 854 dev_warn(&client->dev, "Initialization failed!\n");
853 return; 855 return;
854 } 856 }
855 config_orig = config; 857 data->config_orig = config;
856 858
857 /* Check Temperature Range Select */ 859 /* Check Temperature Range Select */
858 if (data->kind == adt7461) { 860 if (data->kind == adt7461) {
@@ -870,7 +872,7 @@ static void lm90_init_client(struct i2c_client *client)
870 } 872 }
871 873
872 config &= 0xBF; /* run */ 874 config &= 0xBF; /* run */
873 if (config != config_orig) /* Only write if changed */ 875 if (config != data->config_orig) /* Only write if changed */
874 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); 876 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
875} 877}
876 878
@@ -885,6 +887,10 @@ static int lm90_remove(struct i2c_client *client)
885 device_remove_file(&client->dev, 887 device_remove_file(&client->dev,
886 &sensor_dev_attr_temp2_offset.dev_attr); 888 &sensor_dev_attr_temp2_offset.dev_attr);
887 889
890 /* Restore initial configuration */
891 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
892 data->config_orig);
893
888 kfree(data); 894 kfree(data);
889 return 0; 895 return 0;
890} 896}