diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/hwmon/lm83.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/hwmon/lm83.c')
-rw-r--r-- | drivers/hwmon/lm83.c | 93 |
1 files changed, 30 insertions, 63 deletions
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index e59e2d1f080c..8290476aee4a 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is | 6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is |
7 | * a sensor chip made by National Semiconductor. It reports up to four | 7 | * a sensor chip made by National Semiconductor. It reports up to four |
@@ -51,11 +51,7 @@ | |||
51 | static const unsigned short normal_i2c[] = { | 51 | static const unsigned short normal_i2c[] = { |
52 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; | 52 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
53 | 53 | ||
54 | /* | 54 | enum chips { lm83, lm82 }; |
55 | * Insmod parameters | ||
56 | */ | ||
57 | |||
58 | I2C_CLIENT_INSMOD_2(lm83, lm82); | ||
59 | 55 | ||
60 | /* | 56 | /* |
61 | * The LM83 registers | 57 | * The LM83 registers |
@@ -118,7 +114,7 @@ static const u8 LM83_REG_W_HIGH[] = { | |||
118 | * Functions declaration | 114 | * Functions declaration |
119 | */ | 115 | */ |
120 | 116 | ||
121 | static int lm83_detect(struct i2c_client *new_client, int kind, | 117 | static int lm83_detect(struct i2c_client *new_client, |
122 | struct i2c_board_info *info); | 118 | struct i2c_board_info *info); |
123 | static int lm83_probe(struct i2c_client *client, | 119 | static int lm83_probe(struct i2c_client *client, |
124 | const struct i2c_device_id *id); | 120 | const struct i2c_device_id *id); |
@@ -145,7 +141,7 @@ static struct i2c_driver lm83_driver = { | |||
145 | .remove = lm83_remove, | 141 | .remove = lm83_remove, |
146 | .id_table = lm83_id, | 142 | .id_table = lm83_id, |
147 | .detect = lm83_detect, | 143 | .detect = lm83_detect, |
148 | .address_data = &addr_data, | 144 | .address_list = normal_i2c, |
149 | }; | 145 | }; |
150 | 146 | ||
151 | /* | 147 | /* |
@@ -291,73 +287,44 @@ static const struct attribute_group lm83_group_opt = { | |||
291 | */ | 287 | */ |
292 | 288 | ||
293 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 289 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
294 | static int lm83_detect(struct i2c_client *new_client, int kind, | 290 | static int lm83_detect(struct i2c_client *new_client, |
295 | struct i2c_board_info *info) | 291 | struct i2c_board_info *info) |
296 | { | 292 | { |
297 | struct i2c_adapter *adapter = new_client->adapter; | 293 | struct i2c_adapter *adapter = new_client->adapter; |
298 | const char *name = ""; | 294 | const char *name; |
295 | u8 man_id, chip_id; | ||
299 | 296 | ||
300 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 297 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
301 | return -ENODEV; | 298 | return -ENODEV; |
302 | 299 | ||
303 | /* Now we do the detection and identification. A negative kind | 300 | /* Detection */ |
304 | * means that the driver was loaded with no force parameter | 301 | if ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) & 0xA8) || |
305 | * (default), so we must both detect and identify the chip | 302 | (i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) & 0x48) || |
306 | * (actually there is only one possible kind of chip for now, LM83). | 303 | (i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) & 0x41)) { |
307 | * A zero kind means that the driver was loaded with the force | 304 | dev_dbg(&adapter->dev, "LM83 detection failed at 0x%02x\n", |
308 | * parameter, the detection step shall be skipped. A positive kind | 305 | new_client->addr); |
309 | * means that the driver was loaded with the force parameter and a | 306 | return -ENODEV; |
310 | * given kind of chip is requested, so both the detection and the | ||
311 | * identification steps are skipped. */ | ||
312 | |||
313 | /* Default to an LM83 if forced */ | ||
314 | if (kind == 0) | ||
315 | kind = lm83; | ||
316 | |||
317 | if (kind < 0) { /* detection */ | ||
318 | if (((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) | ||
319 | & 0xA8) != 0x00) || | ||
320 | ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) | ||
321 | & 0x48) != 0x00) || | ||
322 | ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) | ||
323 | & 0x41) != 0x00)) { | ||
324 | dev_dbg(&adapter->dev, | ||
325 | "LM83 detection failed at 0x%02x.\n", | ||
326 | new_client->addr); | ||
327 | return -ENODEV; | ||
328 | } | ||
329 | } | 307 | } |
330 | 308 | ||
331 | if (kind <= 0) { /* identification */ | 309 | /* Identification */ |
332 | u8 man_id, chip_id; | 310 | man_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_MAN_ID); |
333 | 311 | if (man_id != 0x01) /* National Semiconductor */ | |
334 | man_id = i2c_smbus_read_byte_data(new_client, | 312 | return -ENODEV; |
335 | LM83_REG_R_MAN_ID); | ||
336 | chip_id = i2c_smbus_read_byte_data(new_client, | ||
337 | LM83_REG_R_CHIP_ID); | ||
338 | |||
339 | if (man_id == 0x01) { /* National Semiconductor */ | ||
340 | if (chip_id == 0x03) { | ||
341 | kind = lm83; | ||
342 | } else | ||
343 | if (chip_id == 0x01) { | ||
344 | kind = lm82; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | if (kind <= 0) { /* identification failed */ | ||
349 | dev_info(&adapter->dev, | ||
350 | "Unsupported chip (man_id=0x%02X, " | ||
351 | "chip_id=0x%02X).\n", man_id, chip_id); | ||
352 | return -ENODEV; | ||
353 | } | ||
354 | } | ||
355 | 313 | ||
356 | if (kind == lm83) { | 314 | chip_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_CHIP_ID); |
315 | switch (chip_id) { | ||
316 | case 0x03: | ||
357 | name = "lm83"; | 317 | name = "lm83"; |
358 | } else | 318 | break; |
359 | if (kind == lm82) { | 319 | case 0x01: |
360 | name = "lm82"; | 320 | name = "lm82"; |
321 | break; | ||
322 | default: | ||
323 | /* identification failed */ | ||
324 | dev_info(&adapter->dev, | ||
325 | "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n", | ||
326 | man_id, chip_id); | ||
327 | return -ENODEV; | ||
361 | } | 328 | } |
362 | 329 | ||
363 | strlcpy(info->type, name, I2C_NAME_SIZE); | 330 | strlcpy(info->type, name, I2C_NAME_SIZE); |