hwmon: (lm77) 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>
This commit is contained in:
Jean Delvare 2009-12-09 20:35:52 +01:00
parent 9560672369
commit 747d9bedc3

View File

@ -249,6 +249,7 @@ static int lm77_detect(struct i2c_client *new_client, int kind,
struct i2c_board_info *info)
{
struct i2c_adapter *adapter = new_client->adapter;
int i, cur, conf, hyst, crit, min, max;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_WORD_DATA))
@ -265,8 +266,6 @@ static int lm77_detect(struct i2c_client *new_client, int kind,
4. registers cycling over 8-address boundaries
Word-sized registers are high-byte first. */
if (kind < 0) {
int i, cur, conf, hyst, crit, min, max;
/* addresses cycling */
cur = i2c_smbus_read_word_data(new_client, 0);
@ -275,13 +274,14 @@ static int lm77_detect(struct i2c_client *new_client, int kind,
crit = i2c_smbus_read_word_data(new_client, 3);
min = i2c_smbus_read_word_data(new_client, 4);
max = i2c_smbus_read_word_data(new_client, 5);
for (i = 8; i <= 0xff; i += 8)
for (i = 8; i <= 0xff; i += 8) {
if (i2c_smbus_read_byte_data(new_client, i + 1) != conf
|| i2c_smbus_read_word_data(new_client, i + 2) != hyst
|| i2c_smbus_read_word_data(new_client, i + 3) != crit
|| i2c_smbus_read_word_data(new_client, i + 4) != min
|| i2c_smbus_read_word_data(new_client, i + 5) != max)
return -ENODEV;
}
/* sign bits */
if (((cur & 0x00f0) != 0xf0 && (cur & 0x00f0) != 0x0)
@ -309,8 +309,6 @@ static int lm77_detect(struct i2c_client *new_client, int kind,
|| i2c_smbus_read_word_data(new_client, 7) != min)
return -ENODEV;
}
strlcpy(info->type, "lm77", I2C_NAME_SIZE);
return 0;