mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
hwmon: (pmbus/ltc2978) Use pmbus_read_smbus_i2c_block_data for block commands
The driver uses a mix of pmbus_read_smbus_i2c_block_data() and i2c_smbus_read_i2c_block_data() for PMBus block commands. Use pmbus_read_smbus_i2c_block_data() instead to enable the driver to work I2C controllers which do not support both block commands. Drop the functionality check to simplify the code and to trigger a return with -EOPNOTSUPP if SMBus block commands are not supported. As part of this patch, rework detection of LT7170 and LT7171. The return length of pmbus_read_smbus_i2c_block_data() may be less than the requested number of bytes, meaning the return length needs to be checked. Also, checking for "LT7170-1" after checking for "LT7170" and checking for "LT7171-1" after checking for "LT7171" is pointless since the first check will already produce a match, so drop the second part of the check. Cc: Alexis Czezar Torreno <alexisczezar.torreno@analog.com> Cc: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
5b3dfe24a1
commit
08007275d5
|
|
@ -611,17 +611,13 @@ static int ltc2978_get_id(struct i2c_client *client)
|
|||
u8 buf[I2C_SMBUS_BLOCK_MAX];
|
||||
int ret;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_BLOCK_DATA))
|
||||
return -ENODEV;
|
||||
|
||||
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
|
||||
ret = pmbus_read_smbus_i2c_block_data(client, PMBUS_MFR_ID, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret < 3 || (strncmp(buf, "LTC", 3) && strncmp(buf, "ADI", 3)))
|
||||
return -ENODEV;
|
||||
|
||||
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
|
||||
ret = pmbus_read_smbus_i2c_block_data(client, PMBUS_MFR_MODEL, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
for (id = <c2978_id[0]; strlen(id->name); id++) {
|
||||
|
|
@ -637,16 +633,17 @@ static int ltc2978_get_id(struct i2c_client *client)
|
|||
u8 buf[I2C_SMBUS_BLOCK_MAX];
|
||||
int ret;
|
||||
|
||||
ret = i2c_smbus_read_i2c_block_data(client, PMBUS_IC_DEVICE_ID,
|
||||
sizeof(buf), buf);
|
||||
ret = pmbus_read_smbus_i2c_block_data(client, PMBUS_IC_DEVICE_ID,
|
||||
buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (!strncmp(buf + 1, "LT7170", 6) ||
|
||||
!strncmp(buf + 1, "LT7170-1", 8))
|
||||
if (ret < 6)
|
||||
return -ENODEV;
|
||||
|
||||
if (!strncmp(buf, "LT7170", 6))
|
||||
return lt7170;
|
||||
if (!strncmp(buf + 1, "LT7171", 6) ||
|
||||
!strncmp(buf + 1, "LT7171-1", 8))
|
||||
if (!strncmp(buf, "LT7171", 6))
|
||||
return lt7171;
|
||||
|
||||
return -ENODEV;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user