diff options
author | Jean Delvare <khali@linux-fr.org> | 2012-01-26 12:37:50 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:41 -0400 |
commit | 8652a2642ce70074d3ef9bd2b565e62e851b0070 (patch) | |
tree | a13467032899ec973f651e22f8461ac3d42d4a93 | |
parent | 0fc86eca1b338d06ec500b34ef7def79c32b602b (diff) |
hwmon: (lm87) Reorganize the code
Reorder functions and driver declaration to no longer need to
forward-declare functions. Also rename new_client to just client
everywhere for readability.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
-rw-r--r-- | drivers/hwmon/lm87.c | 351 |
1 files changed, 165 insertions, 186 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index e35f9af03b6a..a71c7492fc49 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -150,41 +150,6 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C }; | |||
150 | #define CHAN_NO_VID (1 << 7) | 150 | #define CHAN_NO_VID (1 << 7) |
151 | 151 | ||
152 | /* | 152 | /* |
153 | * Functions declaration | ||
154 | */ | ||
155 | |||
156 | static int lm87_probe(struct i2c_client *client, | ||
157 | const struct i2c_device_id *id); | ||
158 | static int lm87_detect(struct i2c_client *new_client, | ||
159 | struct i2c_board_info *info); | ||
160 | static void lm87_init_client(struct i2c_client *client); | ||
161 | static int lm87_remove(struct i2c_client *client); | ||
162 | static struct lm87_data *lm87_update_device(struct device *dev); | ||
163 | |||
164 | /* | ||
165 | * Driver data (common to all clients) | ||
166 | */ | ||
167 | |||
168 | static const struct i2c_device_id lm87_id[] = { | ||
169 | { "lm87", lm87 }, | ||
170 | { "adm1024", adm1024 }, | ||
171 | { } | ||
172 | }; | ||
173 | MODULE_DEVICE_TABLE(i2c, lm87_id); | ||
174 | |||
175 | static struct i2c_driver lm87_driver = { | ||
176 | .class = I2C_CLASS_HWMON, | ||
177 | .driver = { | ||
178 | .name = "lm87", | ||
179 | }, | ||
180 | .probe = lm87_probe, | ||
181 | .remove = lm87_remove, | ||
182 | .id_table = lm87_id, | ||
183 | .detect = lm87_detect, | ||
184 | .address_list = normal_i2c, | ||
185 | }; | ||
186 | |||
187 | /* | ||
188 | * Client data (each client gets its own) | 153 | * Client data (each client gets its own) |
189 | */ | 154 | */ |
190 | 155 | ||
@@ -218,10 +183,6 @@ struct lm87_data { | |||
218 | u8 vrm; | 183 | u8 vrm; |
219 | }; | 184 | }; |
220 | 185 | ||
221 | /* | ||
222 | * Sysfs stuff | ||
223 | */ | ||
224 | |||
225 | static inline int lm87_read_value(struct i2c_client *client, u8 reg) | 186 | static inline int lm87_read_value(struct i2c_client *client, u8 reg) |
226 | { | 187 | { |
227 | return i2c_smbus_read_byte_data(client, reg); | 188 | return i2c_smbus_read_byte_data(client, reg); |
@@ -232,6 +193,89 @@ static inline int lm87_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
232 | return i2c_smbus_write_byte_data(client, reg, value); | 193 | return i2c_smbus_write_byte_data(client, reg, value); |
233 | } | 194 | } |
234 | 195 | ||
196 | static struct lm87_data *lm87_update_device(struct device *dev) | ||
197 | { | ||
198 | struct i2c_client *client = to_i2c_client(dev); | ||
199 | struct lm87_data *data = i2c_get_clientdata(client); | ||
200 | |||
201 | mutex_lock(&data->update_lock); | ||
202 | |||
203 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | ||
204 | int i, j; | ||
205 | |||
206 | dev_dbg(&client->dev, "Updating data.\n"); | ||
207 | |||
208 | i = (data->channel & CHAN_TEMP3) ? 1 : 0; | ||
209 | j = (data->channel & CHAN_TEMP3) ? 5 : 6; | ||
210 | for (; i < j; i++) { | ||
211 | data->in[i] = lm87_read_value(client, | ||
212 | LM87_REG_IN(i)); | ||
213 | data->in_min[i] = lm87_read_value(client, | ||
214 | LM87_REG_IN_MIN(i)); | ||
215 | data->in_max[i] = lm87_read_value(client, | ||
216 | LM87_REG_IN_MAX(i)); | ||
217 | } | ||
218 | |||
219 | for (i = 0; i < 2; i++) { | ||
220 | if (data->channel & CHAN_NO_FAN(i)) { | ||
221 | data->in[6+i] = lm87_read_value(client, | ||
222 | LM87_REG_AIN(i)); | ||
223 | data->in_max[6+i] = lm87_read_value(client, | ||
224 | LM87_REG_AIN_MAX(i)); | ||
225 | data->in_min[6+i] = lm87_read_value(client, | ||
226 | LM87_REG_AIN_MIN(i)); | ||
227 | |||
228 | } else { | ||
229 | data->fan[i] = lm87_read_value(client, | ||
230 | LM87_REG_FAN(i)); | ||
231 | data->fan_min[i] = lm87_read_value(client, | ||
232 | LM87_REG_FAN_MIN(i)); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | j = (data->channel & CHAN_TEMP3) ? 3 : 2; | ||
237 | for (i = 0 ; i < j; i++) { | ||
238 | data->temp[i] = lm87_read_value(client, | ||
239 | LM87_REG_TEMP[i]); | ||
240 | data->temp_high[i] = lm87_read_value(client, | ||
241 | LM87_REG_TEMP_HIGH[i]); | ||
242 | data->temp_low[i] = lm87_read_value(client, | ||
243 | LM87_REG_TEMP_LOW[i]); | ||
244 | } | ||
245 | |||
246 | i = lm87_read_value(client, LM87_REG_TEMP_HW_INT_LOCK); | ||
247 | j = lm87_read_value(client, LM87_REG_TEMP_HW_INT); | ||
248 | data->temp_crit_int = min(i, j); | ||
249 | |||
250 | i = lm87_read_value(client, LM87_REG_TEMP_HW_EXT_LOCK); | ||
251 | j = lm87_read_value(client, LM87_REG_TEMP_HW_EXT); | ||
252 | data->temp_crit_ext = min(i, j); | ||
253 | |||
254 | i = lm87_read_value(client, LM87_REG_VID_FAN_DIV); | ||
255 | data->fan_div[0] = (i >> 4) & 0x03; | ||
256 | data->fan_div[1] = (i >> 6) & 0x03; | ||
257 | data->vid = (i & 0x0F) | ||
258 | | (lm87_read_value(client, LM87_REG_VID4) & 0x01) | ||
259 | << 4; | ||
260 | |||
261 | data->alarms = lm87_read_value(client, LM87_REG_ALARMS1) | ||
262 | | (lm87_read_value(client, LM87_REG_ALARMS2) | ||
263 | << 8); | ||
264 | data->aout = lm87_read_value(client, LM87_REG_AOUT); | ||
265 | |||
266 | data->last_updated = jiffies; | ||
267 | data->valid = 1; | ||
268 | } | ||
269 | |||
270 | mutex_unlock(&data->update_lock); | ||
271 | |||
272 | return data; | ||
273 | } | ||
274 | |||
275 | /* | ||
276 | * Sysfs stuff | ||
277 | */ | ||
278 | |||
235 | #define show_in(offset) \ | 279 | #define show_in(offset) \ |
236 | static ssize_t show_in##offset##_input(struct device *dev, \ | 280 | static ssize_t show_in##offset##_input(struct device *dev, \ |
237 | struct device_attribute *attr, \ | 281 | struct device_attribute *attr, \ |
@@ -789,22 +833,21 @@ static const struct attribute_group lm87_group_vid = { | |||
789 | }; | 833 | }; |
790 | 834 | ||
791 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 835 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
792 | static int lm87_detect(struct i2c_client *new_client, | 836 | static int lm87_detect(struct i2c_client *client, struct i2c_board_info *info) |
793 | struct i2c_board_info *info) | ||
794 | { | 837 | { |
795 | struct i2c_adapter *adapter = new_client->adapter; | 838 | struct i2c_adapter *adapter = client->adapter; |
796 | const char *name; | 839 | const char *name; |
797 | u8 cid, rev; | 840 | u8 cid, rev; |
798 | 841 | ||
799 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 842 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
800 | return -ENODEV; | 843 | return -ENODEV; |
801 | 844 | ||
802 | if (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) | 845 | if (lm87_read_value(client, LM87_REG_CONFIG) & 0x80) |
803 | return -ENODEV; | 846 | return -ENODEV; |
804 | 847 | ||
805 | /* Now, we do the remaining detection. */ | 848 | /* Now, we do the remaining detection. */ |
806 | cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); | 849 | cid = lm87_read_value(client, LM87_REG_COMPANY_ID); |
807 | rev = lm87_read_value(new_client, LM87_REG_REVISION); | 850 | rev = lm87_read_value(client, LM87_REG_REVISION); |
808 | 851 | ||
809 | if (cid == 0x02 /* National Semiconductor */ | 852 | if (cid == 0x02 /* National Semiconductor */ |
810 | && (rev >= 0x01 && rev <= 0x08)) | 853 | && (rev >= 0x01 && rev <= 0x08)) |
@@ -814,7 +857,7 @@ static int lm87_detect(struct i2c_client *new_client, | |||
814 | name = "adm1024"; | 857 | name = "adm1024"; |
815 | else { | 858 | else { |
816 | dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n", | 859 | dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n", |
817 | new_client->addr); | 860 | client->addr); |
818 | return -ENODEV; | 861 | return -ENODEV; |
819 | } | 862 | } |
820 | 863 | ||
@@ -837,8 +880,49 @@ static void lm87_remove_files(struct i2c_client *client) | |||
837 | sysfs_remove_group(&dev->kobj, &lm87_group_vid); | 880 | sysfs_remove_group(&dev->kobj, &lm87_group_vid); |
838 | } | 881 | } |
839 | 882 | ||
840 | static int lm87_probe(struct i2c_client *new_client, | 883 | static void lm87_init_client(struct i2c_client *client) |
841 | const struct i2c_device_id *id) | 884 | { |
885 | struct lm87_data *data = i2c_get_clientdata(client); | ||
886 | |||
887 | if (client->dev.platform_data) { | ||
888 | data->channel = *(u8 *)client->dev.platform_data; | ||
889 | lm87_write_value(client, | ||
890 | LM87_REG_CHANNEL_MODE, data->channel); | ||
891 | } else { | ||
892 | data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); | ||
893 | } | ||
894 | data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F; | ||
895 | |||
896 | if (!(data->config & 0x01)) { | ||
897 | int i; | ||
898 | |||
899 | /* Limits are left uninitialized after power-up */ | ||
900 | for (i = 1; i < 6; i++) { | ||
901 | lm87_write_value(client, LM87_REG_IN_MIN(i), 0x00); | ||
902 | lm87_write_value(client, LM87_REG_IN_MAX(i), 0xFF); | ||
903 | } | ||
904 | for (i = 0; i < 2; i++) { | ||
905 | lm87_write_value(client, LM87_REG_TEMP_HIGH[i], 0x7F); | ||
906 | lm87_write_value(client, LM87_REG_TEMP_LOW[i], 0x00); | ||
907 | lm87_write_value(client, LM87_REG_AIN_MIN(i), 0x00); | ||
908 | lm87_write_value(client, LM87_REG_AIN_MAX(i), 0xFF); | ||
909 | } | ||
910 | if (data->channel & CHAN_TEMP3) { | ||
911 | lm87_write_value(client, LM87_REG_TEMP_HIGH[2], 0x7F); | ||
912 | lm87_write_value(client, LM87_REG_TEMP_LOW[2], 0x00); | ||
913 | } else { | ||
914 | lm87_write_value(client, LM87_REG_IN_MIN(0), 0x00); | ||
915 | lm87_write_value(client, LM87_REG_IN_MAX(0), 0xFF); | ||
916 | } | ||
917 | } | ||
918 | |||
919 | /* Make sure Start is set and INT#_Clear is clear */ | ||
920 | if ((data->config & 0x09) != 0x01) | ||
921 | lm87_write_value(client, LM87_REG_CONFIG, | ||
922 | (data->config & 0x77) | 0x01); | ||
923 | } | ||
924 | |||
925 | static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id) | ||
842 | { | 926 | { |
843 | struct lm87_data *data; | 927 | struct lm87_data *data; |
844 | int err; | 928 | int err; |
@@ -849,12 +933,12 @@ static int lm87_probe(struct i2c_client *new_client, | |||
849 | goto exit; | 933 | goto exit; |
850 | } | 934 | } |
851 | 935 | ||
852 | i2c_set_clientdata(new_client, data); | 936 | i2c_set_clientdata(client, data); |
853 | data->valid = 0; | 937 | data->valid = 0; |
854 | mutex_init(&data->update_lock); | 938 | mutex_init(&data->update_lock); |
855 | 939 | ||
856 | /* Initialize the LM87 chip */ | 940 | /* Initialize the LM87 chip */ |
857 | lm87_init_client(new_client); | 941 | lm87_init_client(client); |
858 | 942 | ||
859 | data->in_scale[0] = 2500; | 943 | data->in_scale[0] = 2500; |
860 | data->in_scale[1] = 2700; | 944 | data->in_scale[1] = 2700; |
@@ -866,55 +950,48 @@ static int lm87_probe(struct i2c_client *new_client, | |||
866 | data->in_scale[7] = 1875; | 950 | data->in_scale[7] = 1875; |
867 | 951 | ||
868 | /* Register sysfs hooks */ | 952 | /* Register sysfs hooks */ |
869 | err = sysfs_create_group(&new_client->dev.kobj, &lm87_group); | 953 | err = sysfs_create_group(&client->dev.kobj, &lm87_group); |
870 | if (err) | 954 | if (err) |
871 | goto exit_free; | 955 | goto exit_free; |
872 | 956 | ||
873 | if (data->channel & CHAN_NO_FAN(0)) { | 957 | if (data->channel & CHAN_NO_FAN(0)) { |
874 | err = sysfs_create_group(&new_client->dev.kobj, | 958 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_in6); |
875 | &lm87_group_in6); | ||
876 | if (err) | 959 | if (err) |
877 | goto exit_remove; | 960 | goto exit_remove; |
878 | } else { | 961 | } else { |
879 | err = sysfs_create_group(&new_client->dev.kobj, | 962 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_fan1); |
880 | &lm87_group_fan1); | ||
881 | if (err) | 963 | if (err) |
882 | goto exit_remove; | 964 | goto exit_remove; |
883 | } | 965 | } |
884 | 966 | ||
885 | if (data->channel & CHAN_NO_FAN(1)) { | 967 | if (data->channel & CHAN_NO_FAN(1)) { |
886 | err = sysfs_create_group(&new_client->dev.kobj, | 968 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_in7); |
887 | &lm87_group_in7); | ||
888 | if (err) | 969 | if (err) |
889 | goto exit_remove; | 970 | goto exit_remove; |
890 | } else { | 971 | } else { |
891 | err = sysfs_create_group(&new_client->dev.kobj, | 972 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_fan2); |
892 | &lm87_group_fan2); | ||
893 | if (err) | 973 | if (err) |
894 | goto exit_remove; | 974 | goto exit_remove; |
895 | } | 975 | } |
896 | 976 | ||
897 | if (data->channel & CHAN_TEMP3) { | 977 | if (data->channel & CHAN_TEMP3) { |
898 | err = sysfs_create_group(&new_client->dev.kobj, | 978 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_temp3); |
899 | &lm87_group_temp3); | ||
900 | if (err) | 979 | if (err) |
901 | goto exit_remove; | 980 | goto exit_remove; |
902 | } else { | 981 | } else { |
903 | err = sysfs_create_group(&new_client->dev.kobj, | 982 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_in0_5); |
904 | &lm87_group_in0_5); | ||
905 | if (err) | 983 | if (err) |
906 | goto exit_remove; | 984 | goto exit_remove; |
907 | } | 985 | } |
908 | 986 | ||
909 | if (!(data->channel & CHAN_NO_VID)) { | 987 | if (!(data->channel & CHAN_NO_VID)) { |
910 | data->vrm = vid_which_vrm(); | 988 | data->vrm = vid_which_vrm(); |
911 | err = sysfs_create_group(&new_client->dev.kobj, | 989 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_vid); |
912 | &lm87_group_vid); | ||
913 | if (err) | 990 | if (err) |
914 | goto exit_remove; | 991 | goto exit_remove; |
915 | } | 992 | } |
916 | 993 | ||
917 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 994 | data->hwmon_dev = hwmon_device_register(&client->dev); |
918 | if (IS_ERR(data->hwmon_dev)) { | 995 | if (IS_ERR(data->hwmon_dev)) { |
919 | err = PTR_ERR(data->hwmon_dev); | 996 | err = PTR_ERR(data->hwmon_dev); |
920 | goto exit_remove; | 997 | goto exit_remove; |
@@ -923,56 +1000,14 @@ static int lm87_probe(struct i2c_client *new_client, | |||
923 | return 0; | 1000 | return 0; |
924 | 1001 | ||
925 | exit_remove: | 1002 | exit_remove: |
926 | lm87_remove_files(new_client); | 1003 | lm87_remove_files(client); |
927 | exit_free: | 1004 | exit_free: |
928 | lm87_write_value(new_client, LM87_REG_CONFIG, data->config); | 1005 | lm87_write_value(client, LM87_REG_CONFIG, data->config); |
929 | kfree(data); | 1006 | kfree(data); |
930 | exit: | 1007 | exit: |
931 | return err; | 1008 | return err; |
932 | } | 1009 | } |
933 | 1010 | ||
934 | static void lm87_init_client(struct i2c_client *client) | ||
935 | { | ||
936 | struct lm87_data *data = i2c_get_clientdata(client); | ||
937 | |||
938 | if (client->dev.platform_data) { | ||
939 | data->channel = *(u8 *)client->dev.platform_data; | ||
940 | lm87_write_value(client, | ||
941 | LM87_REG_CHANNEL_MODE, data->channel); | ||
942 | } else { | ||
943 | data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); | ||
944 | } | ||
945 | data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F; | ||
946 | |||
947 | if (!(data->config & 0x01)) { | ||
948 | int i; | ||
949 | |||
950 | /* Limits are left uninitialized after power-up */ | ||
951 | for (i = 1; i < 6; i++) { | ||
952 | lm87_write_value(client, LM87_REG_IN_MIN(i), 0x00); | ||
953 | lm87_write_value(client, LM87_REG_IN_MAX(i), 0xFF); | ||
954 | } | ||
955 | for (i = 0; i < 2; i++) { | ||
956 | lm87_write_value(client, LM87_REG_TEMP_HIGH[i], 0x7F); | ||
957 | lm87_write_value(client, LM87_REG_TEMP_LOW[i], 0x00); | ||
958 | lm87_write_value(client, LM87_REG_AIN_MIN(i), 0x00); | ||
959 | lm87_write_value(client, LM87_REG_AIN_MAX(i), 0xFF); | ||
960 | } | ||
961 | if (data->channel & CHAN_TEMP3) { | ||
962 | lm87_write_value(client, LM87_REG_TEMP_HIGH[2], 0x7F); | ||
963 | lm87_write_value(client, LM87_REG_TEMP_LOW[2], 0x00); | ||
964 | } else { | ||
965 | lm87_write_value(client, LM87_REG_IN_MIN(0), 0x00); | ||
966 | lm87_write_value(client, LM87_REG_IN_MAX(0), 0xFF); | ||
967 | } | ||
968 | } | ||
969 | |||
970 | /* Make sure Start is set and INT#_Clear is clear */ | ||
971 | if ((data->config & 0x09) != 0x01) | ||
972 | lm87_write_value(client, LM87_REG_CONFIG, | ||
973 | (data->config & 0x77) | 0x01); | ||
974 | } | ||
975 | |||
976 | static int lm87_remove(struct i2c_client *client) | 1011 | static int lm87_remove(struct i2c_client *client) |
977 | { | 1012 | { |
978 | struct lm87_data *data = i2c_get_clientdata(client); | 1013 | struct lm87_data *data = i2c_get_clientdata(client); |
@@ -985,84 +1020,28 @@ static int lm87_remove(struct i2c_client *client) | |||
985 | return 0; | 1020 | return 0; |
986 | } | 1021 | } |
987 | 1022 | ||
988 | static struct lm87_data *lm87_update_device(struct device *dev) | 1023 | /* |
989 | { | 1024 | * Driver data (common to all clients) |
990 | struct i2c_client *client = to_i2c_client(dev); | 1025 | */ |
991 | struct lm87_data *data = i2c_get_clientdata(client); | ||
992 | |||
993 | mutex_lock(&data->update_lock); | ||
994 | |||
995 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | ||
996 | int i, j; | ||
997 | |||
998 | dev_dbg(&client->dev, "Updating data.\n"); | ||
999 | |||
1000 | i = (data->channel & CHAN_TEMP3) ? 1 : 0; | ||
1001 | j = (data->channel & CHAN_TEMP3) ? 5 : 6; | ||
1002 | for (; i < j; i++) { | ||
1003 | data->in[i] = lm87_read_value(client, | ||
1004 | LM87_REG_IN(i)); | ||
1005 | data->in_min[i] = lm87_read_value(client, | ||
1006 | LM87_REG_IN_MIN(i)); | ||
1007 | data->in_max[i] = lm87_read_value(client, | ||
1008 | LM87_REG_IN_MAX(i)); | ||
1009 | } | ||
1010 | |||
1011 | for (i = 0; i < 2; i++) { | ||
1012 | if (data->channel & CHAN_NO_FAN(i)) { | ||
1013 | data->in[6+i] = lm87_read_value(client, | ||
1014 | LM87_REG_AIN(i)); | ||
1015 | data->in_max[6+i] = lm87_read_value(client, | ||
1016 | LM87_REG_AIN_MAX(i)); | ||
1017 | data->in_min[6+i] = lm87_read_value(client, | ||
1018 | LM87_REG_AIN_MIN(i)); | ||
1019 | |||
1020 | } else { | ||
1021 | data->fan[i] = lm87_read_value(client, | ||
1022 | LM87_REG_FAN(i)); | ||
1023 | data->fan_min[i] = lm87_read_value(client, | ||
1024 | LM87_REG_FAN_MIN(i)); | ||
1025 | } | ||
1026 | } | ||
1027 | |||
1028 | j = (data->channel & CHAN_TEMP3) ? 3 : 2; | ||
1029 | for (i = 0 ; i < j; i++) { | ||
1030 | data->temp[i] = lm87_read_value(client, | ||
1031 | LM87_REG_TEMP[i]); | ||
1032 | data->temp_high[i] = lm87_read_value(client, | ||
1033 | LM87_REG_TEMP_HIGH[i]); | ||
1034 | data->temp_low[i] = lm87_read_value(client, | ||
1035 | LM87_REG_TEMP_LOW[i]); | ||
1036 | } | ||
1037 | |||
1038 | i = lm87_read_value(client, LM87_REG_TEMP_HW_INT_LOCK); | ||
1039 | j = lm87_read_value(client, LM87_REG_TEMP_HW_INT); | ||
1040 | data->temp_crit_int = min(i, j); | ||
1041 | |||
1042 | i = lm87_read_value(client, LM87_REG_TEMP_HW_EXT_LOCK); | ||
1043 | j = lm87_read_value(client, LM87_REG_TEMP_HW_EXT); | ||
1044 | data->temp_crit_ext = min(i, j); | ||
1045 | |||
1046 | i = lm87_read_value(client, LM87_REG_VID_FAN_DIV); | ||
1047 | data->fan_div[0] = (i >> 4) & 0x03; | ||
1048 | data->fan_div[1] = (i >> 6) & 0x03; | ||
1049 | data->vid = (i & 0x0F) | ||
1050 | | (lm87_read_value(client, LM87_REG_VID4) & 0x01) | ||
1051 | << 4; | ||
1052 | |||
1053 | data->alarms = lm87_read_value(client, LM87_REG_ALARMS1) | ||
1054 | | (lm87_read_value(client, LM87_REG_ALARMS2) | ||
1055 | << 8); | ||
1056 | data->aout = lm87_read_value(client, LM87_REG_AOUT); | ||
1057 | |||
1058 | data->last_updated = jiffies; | ||
1059 | data->valid = 1; | ||
1060 | } | ||
1061 | 1026 | ||
1062 | mutex_unlock(&data->update_lock); | 1027 | static const struct i2c_device_id lm87_id[] = { |
1028 | { "lm87", lm87 }, | ||
1029 | { "adm1024", adm1024 }, | ||
1030 | { } | ||
1031 | }; | ||
1032 | MODULE_DEVICE_TABLE(i2c, lm87_id); | ||
1063 | 1033 | ||
1064 | return data; | 1034 | static struct i2c_driver lm87_driver = { |
1065 | } | 1035 | .class = I2C_CLASS_HWMON, |
1036 | .driver = { | ||
1037 | .name = "lm87", | ||
1038 | }, | ||
1039 | .probe = lm87_probe, | ||
1040 | .remove = lm87_remove, | ||
1041 | .id_table = lm87_id, | ||
1042 | .detect = lm87_detect, | ||
1043 | .address_list = normal_i2c, | ||
1044 | }; | ||
1066 | 1045 | ||
1067 | module_i2c_driver(lm87_driver); | 1046 | module_i2c_driver(lm87_driver); |
1068 | 1047 | ||