aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm75.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r--drivers/hwmon/lm75.c70
1 files changed, 30 insertions, 40 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 55bd87c15c9a..8ae2cfe2d827 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -32,15 +32,12 @@
32 32
33/* 33/*
34 * This driver handles the LM75 and compatible digital temperature sensors. 34 * This driver handles the LM75 and compatible digital temperature sensors.
35 * Only types which are _not_ listed in I2C_CLIENT_INSMOD_*() need to be
36 * listed here. We start at 9 since I2C_CLIENT_INSMOD_*() currently allow
37 * definition of up to 8 chip types (plus zero).
38 */ 35 */
39 36
40enum lm75_type { /* keep sorted in alphabetical order */ 37enum lm75_type { /* keep sorted in alphabetical order */
41 ds1775 = 9, 38 ds1775,
42 ds75, 39 ds75,
43 /* lm75 -- in I2C_CLIENT_INSMOD_1() */ 40 lm75,
44 lm75a, 41 lm75a,
45 max6625, 42 max6625,
46 max6626, 43 max6626,
@@ -58,9 +55,6 @@ enum lm75_type { /* keep sorted in alphabetical order */
58static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 55static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
59 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 56 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
60 57
61/* Insmod parameters */
62I2C_CLIENT_INSMOD_1(lm75);
63
64 58
65/* The LM75 registers */ 59/* The LM75 registers */
66#define LM75_REG_CONF 0x01 60#define LM75_REG_CONF 0x01
@@ -234,11 +228,12 @@ static const struct i2c_device_id lm75_ids[] = {
234MODULE_DEVICE_TABLE(i2c, lm75_ids); 228MODULE_DEVICE_TABLE(i2c, lm75_ids);
235 229
236/* Return 0 if detection is successful, -ENODEV otherwise */ 230/* Return 0 if detection is successful, -ENODEV otherwise */
237static int lm75_detect(struct i2c_client *new_client, int kind, 231static int lm75_detect(struct i2c_client *new_client,
238 struct i2c_board_info *info) 232 struct i2c_board_info *info)
239{ 233{
240 struct i2c_adapter *adapter = new_client->adapter; 234 struct i2c_adapter *adapter = new_client->adapter;
241 int i; 235 int i;
236 int cur, conf, hyst, os;
242 237
243 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 238 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
244 I2C_FUNC_SMBUS_WORD_DATA)) 239 I2C_FUNC_SMBUS_WORD_DATA))
@@ -251,40 +246,35 @@ static int lm75_detect(struct i2c_client *new_client, int kind,
251 The cycling+unused addresses combination is not tested, 246 The cycling+unused addresses combination is not tested,
252 since it would significantly slow the detection down and would 247 since it would significantly slow the detection down and would
253 hardly add any value. */ 248 hardly add any value. */
254 if (kind < 0) {
255 int cur, conf, hyst, os;
256
257 /* Unused addresses */
258 cur = i2c_smbus_read_word_data(new_client, 0);
259 conf = i2c_smbus_read_byte_data(new_client, 1);
260 hyst = i2c_smbus_read_word_data(new_client, 2);
261 if (i2c_smbus_read_word_data(new_client, 4) != hyst
262 || i2c_smbus_read_word_data(new_client, 5) != hyst
263 || i2c_smbus_read_word_data(new_client, 6) != hyst
264 || i2c_smbus_read_word_data(new_client, 7) != hyst)
265 return -ENODEV;
266 os = i2c_smbus_read_word_data(new_client, 3);
267 if (i2c_smbus_read_word_data(new_client, 4) != os
268 || i2c_smbus_read_word_data(new_client, 5) != os
269 || i2c_smbus_read_word_data(new_client, 6) != os
270 || i2c_smbus_read_word_data(new_client, 7) != os)
271 return -ENODEV;
272 249
273 /* Unused bits */ 250 /* Unused addresses */
274 if (conf & 0xe0) 251 cur = i2c_smbus_read_word_data(new_client, 0);
275 return -ENODEV; 252 conf = i2c_smbus_read_byte_data(new_client, 1);
253 hyst = i2c_smbus_read_word_data(new_client, 2);
254 if (i2c_smbus_read_word_data(new_client, 4) != hyst
255 || i2c_smbus_read_word_data(new_client, 5) != hyst
256 || i2c_smbus_read_word_data(new_client, 6) != hyst
257 || i2c_smbus_read_word_data(new_client, 7) != hyst)
258 return -ENODEV;
259 os = i2c_smbus_read_word_data(new_client, 3);
260 if (i2c_smbus_read_word_data(new_client, 4) != os
261 || i2c_smbus_read_word_data(new_client, 5) != os
262 || i2c_smbus_read_word_data(new_client, 6) != os
263 || i2c_smbus_read_word_data(new_client, 7) != os)
264 return -ENODEV;
265
266 /* Unused bits */
267 if (conf & 0xe0)
268 return -ENODEV;
276 269
277 /* Addresses cycling */ 270 /* Addresses cycling */
278 for (i = 8; i < 0xff; i += 8) 271 for (i = 8; i < 0xff; i += 8) {
279 if (i2c_smbus_read_byte_data(new_client, i + 1) != conf 272 if (i2c_smbus_read_byte_data(new_client, i + 1) != conf
280 || i2c_smbus_read_word_data(new_client, i + 2) != hyst 273 || i2c_smbus_read_word_data(new_client, i + 2) != hyst
281 || i2c_smbus_read_word_data(new_client, i + 3) != os) 274 || i2c_smbus_read_word_data(new_client, i + 3) != os)
282 return -ENODEV; 275 return -ENODEV;
283 } 276 }
284 277
285 /* NOTE: we treat "force=..." and "force_lm75=..." the same.
286 * Only new-style driver binding distinguishes chip types.
287 */
288 strlcpy(info->type, "lm75", I2C_NAME_SIZE); 278 strlcpy(info->type, "lm75", I2C_NAME_SIZE);
289 279
290 return 0; 280 return 0;
@@ -299,7 +289,7 @@ static struct i2c_driver lm75_driver = {
299 .remove = lm75_remove, 289 .remove = lm75_remove,
300 .id_table = lm75_ids, 290 .id_table = lm75_ids,
301 .detect = lm75_detect, 291 .detect = lm75_detect,
302 .address_data = &addr_data, 292 .address_list = normal_i2c,
303}; 293};
304 294
305/*-----------------------------------------------------------------------*/ 295/*-----------------------------------------------------------------------*/