diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-06 11:06:26 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-06 11:06:26 -0500 |
commit | c2e90e9b6835d71cbadd42fe5b38704acaccf8aa (patch) | |
tree | 0e4249f3aa9aa60e5fb405a287261246ffd5d9df /drivers/misc/ics932s401.c | |
parent | ccfbbd082a1c71667bead7124591ccd09f08ac90 (diff) |
ics932s401: Clean up detect function
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: "Darrick J. Wong" <djwong@us.ibm.com>
Diffstat (limited to 'drivers/misc/ics932s401.c')
-rw-r--r-- | drivers/misc/ics932s401.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c index 6e43ab4231ae..4bb7a3af9ad9 100644 --- a/drivers/misc/ics932s401.c +++ b/drivers/misc/ics932s401.c | |||
@@ -417,32 +417,25 @@ static int ics932s401_detect(struct i2c_client *client, int kind, | |||
417 | struct i2c_board_info *info) | 417 | struct i2c_board_info *info) |
418 | { | 418 | { |
419 | struct i2c_adapter *adapter = client->adapter; | 419 | struct i2c_adapter *adapter = client->adapter; |
420 | int vendor, device, revision; | ||
420 | 421 | ||
421 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 422 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
422 | return -ENODEV; | 423 | return -ENODEV; |
423 | 424 | ||
424 | if (kind <= 0) { | 425 | vendor = i2c_smbus_read_word_data(client, ICS932S401_REG_VENDOR_REV); |
425 | int vendor, device, revision; | 426 | vendor >>= 8; |
426 | 427 | revision = vendor >> ICS932S401_REV_SHIFT; | |
427 | vendor = i2c_smbus_read_word_data(client, | 428 | vendor &= ICS932S401_VENDOR_MASK; |
428 | ICS932S401_REG_VENDOR_REV); | 429 | if (vendor != ICS932S401_VENDOR) |
429 | vendor >>= 8; | 430 | return -ENODEV; |
430 | revision = vendor >> ICS932S401_REV_SHIFT; | 431 | |
431 | vendor &= ICS932S401_VENDOR_MASK; | 432 | device = i2c_smbus_read_word_data(client, ICS932S401_REG_DEVICE); |
432 | if (vendor != ICS932S401_VENDOR) | 433 | device >>= 8; |
433 | return -ENODEV; | 434 | if (device != ICS932S401_DEVICE) |
434 | 435 | return -ENODEV; | |
435 | device = i2c_smbus_read_word_data(client, | 436 | |
436 | ICS932S401_REG_DEVICE); | 437 | if (revision != ICS932S401_REV) |
437 | device >>= 8; | 438 | dev_info(&adapter->dev, "Unknown revision %d\n", revision); |
438 | if (device != ICS932S401_DEVICE) | ||
439 | return -ENODEV; | ||
440 | |||
441 | if (revision != ICS932S401_REV) | ||
442 | dev_info(&adapter->dev, "Unknown revision %d\n", | ||
443 | revision); | ||
444 | } else | ||
445 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
446 | 439 | ||
447 | strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); | 440 | strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); |
448 | 441 | ||