diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:57 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:57 -0500 |
commit | 52df6440a29123eed912183fe785bbe174ef14b9 (patch) | |
tree | 3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/lm63.c | |
parent | a1fa4cdcc4abd4c02a81ab7052c16a342d29f060 (diff) |
hwmon: Clean up detect functions
As kind is now hard-coded to -1, there is room for code clean-ups.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Corentin Labbe <corentin.labbe@geomatys.fr>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Juerg Haefliger <juergh@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Acked-by: "Hans J. Koch" <hjk@linutronix.de>
Cc: Rudolf Marek <r.marek@assembler.cz>
Diffstat (limited to 'drivers/hwmon/lm63.c')
-rw-r--r-- | drivers/hwmon/lm63.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 3195a265f0e9..5da66ab04f74 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -427,40 +427,34 @@ static int lm63_detect(struct i2c_client *new_client, int kind, | |||
427 | struct i2c_board_info *info) | 427 | struct i2c_board_info *info) |
428 | { | 428 | { |
429 | struct i2c_adapter *adapter = new_client->adapter; | 429 | struct i2c_adapter *adapter = new_client->adapter; |
430 | u8 man_id, chip_id, reg_config1, reg_config2; | ||
431 | u8 reg_alert_status, reg_alert_mask; | ||
430 | 432 | ||
431 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 433 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
432 | return -ENODEV; | 434 | return -ENODEV; |
433 | 435 | ||
434 | if (kind < 0) { /* must identify */ | 436 | man_id = i2c_smbus_read_byte_data(new_client, LM63_REG_MAN_ID); |
435 | u8 man_id, chip_id, reg_config1, reg_config2; | 437 | chip_id = i2c_smbus_read_byte_data(new_client, LM63_REG_CHIP_ID); |
436 | u8 reg_alert_status, reg_alert_mask; | 438 | |
437 | 439 | reg_config1 = i2c_smbus_read_byte_data(new_client, | |
438 | man_id = i2c_smbus_read_byte_data(new_client, | 440 | LM63_REG_CONFIG1); |
439 | LM63_REG_MAN_ID); | 441 | reg_config2 = i2c_smbus_read_byte_data(new_client, |
440 | chip_id = i2c_smbus_read_byte_data(new_client, | 442 | LM63_REG_CONFIG2); |
441 | LM63_REG_CHIP_ID); | 443 | reg_alert_status = i2c_smbus_read_byte_data(new_client, |
442 | reg_config1 = i2c_smbus_read_byte_data(new_client, | 444 | LM63_REG_ALERT_STATUS); |
443 | LM63_REG_CONFIG1); | 445 | reg_alert_mask = i2c_smbus_read_byte_data(new_client, |
444 | reg_config2 = i2c_smbus_read_byte_data(new_client, | 446 | LM63_REG_ALERT_MASK); |
445 | LM63_REG_CONFIG2); | 447 | |
446 | reg_alert_status = i2c_smbus_read_byte_data(new_client, | 448 | if (man_id != 0x01 /* National Semiconductor */ |
447 | LM63_REG_ALERT_STATUS); | 449 | || chip_id != 0x41 /* LM63 */ |
448 | reg_alert_mask = i2c_smbus_read_byte_data(new_client, | 450 | || (reg_config1 & 0x18) != 0x00 |
449 | LM63_REG_ALERT_MASK); | 451 | || (reg_config2 & 0xF8) != 0x00 |
450 | 452 | || (reg_alert_status & 0x20) != 0x00 | |
451 | if (man_id == 0x01 /* National Semiconductor */ | 453 | || (reg_alert_mask & 0xA4) != 0xA4) { |
452 | && chip_id == 0x41 /* LM63 */ | 454 | dev_dbg(&adapter->dev, |
453 | && (reg_config1 & 0x18) == 0x00 | 455 | "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n", |
454 | && (reg_config2 & 0xF8) == 0x00 | 456 | man_id, chip_id); |
455 | && (reg_alert_status & 0x20) == 0x00 | 457 | return -ENODEV; |
456 | && (reg_alert_mask & 0xA4) == 0xA4) { | ||
457 | kind = lm63; | ||
458 | } else { /* failed */ | ||
459 | dev_dbg(&adapter->dev, "Unsupported chip " | ||
460 | "(man_id=0x%02X, chip_id=0x%02X).\n", | ||
461 | man_id, chip_id); | ||
462 | return -ENODEV; | ||
463 | } | ||
464 | } | 458 | } |
465 | 459 | ||
466 | strlcpy(info->type, "lm63", I2C_NAME_SIZE); | 460 | strlcpy(info->type, "lm63", I2C_NAME_SIZE); |