Skip to content

Commit

Permalink
ics932s401: Clean up detect function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jean Delvare committed Dec 6, 2009
1 parent ccfbbd0 commit c2e90e9
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions drivers/misc/ics932s401.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,32 +417,25 @@ static int ics932s401_detect(struct i2c_client *client, int kind,
struct i2c_board_info *info)
{
struct i2c_adapter *adapter = client->adapter;
int vendor, device, revision;

if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;

if (kind <= 0) {
int vendor, device, revision;

vendor = i2c_smbus_read_word_data(client,
ICS932S401_REG_VENDOR_REV);
vendor >>= 8;
revision = vendor >> ICS932S401_REV_SHIFT;
vendor &= ICS932S401_VENDOR_MASK;
if (vendor != ICS932S401_VENDOR)
return -ENODEV;

device = i2c_smbus_read_word_data(client,
ICS932S401_REG_DEVICE);
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");
vendor = i2c_smbus_read_word_data(client, ICS932S401_REG_VENDOR_REV);
vendor >>= 8;
revision = vendor >> ICS932S401_REV_SHIFT;
vendor &= ICS932S401_VENDOR_MASK;
if (vendor != ICS932S401_VENDOR)
return -ENODEV;

device = i2c_smbus_read_word_data(client, ICS932S401_REG_DEVICE);
device >>= 8;
if (device != ICS932S401_DEVICE)
return -ENODEV;

if (revision != ICS932S401_REV)
dev_info(&adapter->dev, "Unknown revision %d\n", revision);

strlcpy(info->type, "ics932s401", I2C_NAME_SIZE);

Expand Down

0 comments on commit c2e90e9

Please sign in to comment.