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/gl518sm.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/gl518sm.c')
-rw-r--r-- | drivers/hwmon/gl518sm.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 7820df45d77a..1d69458aa0b6 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -488,36 +488,21 @@ static int gl518_detect(struct i2c_client *client, int kind, | |||
488 | struct i2c_board_info *info) | 488 | struct i2c_board_info *info) |
489 | { | 489 | { |
490 | struct i2c_adapter *adapter = client->adapter; | 490 | struct i2c_adapter *adapter = client->adapter; |
491 | int i; | 491 | int rev; |
492 | 492 | ||
493 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 493 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
494 | I2C_FUNC_SMBUS_WORD_DATA)) | 494 | I2C_FUNC_SMBUS_WORD_DATA)) |
495 | return -ENODEV; | 495 | return -ENODEV; |
496 | 496 | ||
497 | /* Now, we do the remaining detection. */ | 497 | /* Now, we do the remaining detection. */ |
498 | 498 | if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80) | |
499 | if (kind < 0) { | 499 | || (gl518_read_value(client, GL518_REG_CONF) & 0x80)) |
500 | if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80) | 500 | return -ENODEV; |
501 | || (gl518_read_value(client, GL518_REG_CONF) & 0x80)) | ||
502 | return -ENODEV; | ||
503 | } | ||
504 | 501 | ||
505 | /* Determine the chip type. */ | 502 | /* Determine the chip type. */ |
506 | if (kind <= 0) { | 503 | rev = gl518_read_value(client, GL518_REG_REVISION); |
507 | i = gl518_read_value(client, GL518_REG_REVISION); | 504 | if (rev != 0x00 && rev != 0x80) |
508 | if (i == 0x00) { | 505 | return -ENODEV; |
509 | kind = gl518sm_r00; | ||
510 | } else if (i == 0x80) { | ||
511 | kind = gl518sm_r80; | ||
512 | } else { | ||
513 | if (kind <= 0) | ||
514 | dev_info(&adapter->dev, | ||
515 | "Ignoring 'force' parameter for unknown " | ||
516 | "chip at adapter %d, address 0x%02x\n", | ||
517 | i2c_adapter_id(adapter), client->addr); | ||
518 | return -ENODEV; | ||
519 | } | ||
520 | } | ||
521 | 506 | ||
522 | strlcpy(info->type, "gl518sm", I2C_NAME_SIZE); | 507 | strlcpy(info->type, "gl518sm", I2C_NAME_SIZE); |
523 | 508 | ||