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>
This commit is contained in:
Jean Delvare 2009-12-06 17:06:26 +01:00
parent ccfbbd082a
commit c2e90e9b68
1 changed files with 13 additions and 20 deletions

View File

@ -417,32 +417,25 @@ static int ics932s401_detect(struct i2c_client *client, int kind,
struct i2c_board_info *info) struct i2c_board_info *info)
{ {
struct i2c_adapter *adapter = client->adapter; struct i2c_adapter *adapter = client->adapter;
int vendor, device, revision;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV; return -ENODEV;
if (kind <= 0) { vendor = i2c_smbus_read_word_data(client, ICS932S401_REG_VENDOR_REV);
int vendor, device, revision; vendor >>= 8;
revision = vendor >> ICS932S401_REV_SHIFT;
vendor &= ICS932S401_VENDOR_MASK;
if (vendor != ICS932S401_VENDOR)
return -ENODEV;
vendor = i2c_smbus_read_word_data(client, device = i2c_smbus_read_word_data(client, ICS932S401_REG_DEVICE);
ICS932S401_REG_VENDOR_REV); device >>= 8;
vendor >>= 8; if (device != ICS932S401_DEVICE)
revision = vendor >> ICS932S401_REV_SHIFT; return -ENODEV;
vendor &= ICS932S401_VENDOR_MASK;
if (vendor != ICS932S401_VENDOR)
return -ENODEV;
device = i2c_smbus_read_word_data(client, if (revision != ICS932S401_REV)
ICS932S401_REG_DEVICE); dev_info(&adapter->dev, "Unknown revision %d\n", revision);
device >>= 8;
if (device != ICS932S401_DEVICE)
return -ENODEV;
if (revision != ICS932S401_REV)
dev_info(&adapter->dev, "Unknown revision %d\n",
revision);
} else
dev_dbg(&adapter->dev, "detection forced\n");
strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); strlcpy(info->type, "ics932s401", I2C_NAME_SIZE);