[PATCH 20/31] hwmon: (pmbus/max16601) use 4-argument i2c_smbus_read_block_data()
From: Dmitry Torokhov
Date: Sat Oct 24 2026 - 23:10:07 EST
Pass the buffer size to i2c_smbus_read_block_data() and shrink the
temporary buffer in max16601_read_word() to I2C_SMBUS_BLOCK_MAX since
it holds binary data and is never NUL-terminated.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hwmon/pmbus/max16601.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/pmbus/max16601.c b/drivers/hwmon/pmbus/max16601.c
index 3dd1f6fd003b..3f4e3c24b985 100644
--- a/drivers/hwmon/pmbus/max16601.c
+++ b/drivers/hwmon/pmbus/max16601.c
@@ -73,7 +73,7 @@ static int max16601_read_word(struct i2c_client *client, int page, int phase,
{
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct max16601_data *data = to_max16601_data(info);
- u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
+ u8 buf[I2C_SMBUS_BLOCK_MAX];
int ret;
switch (page) {
@@ -90,7 +90,7 @@ static int max16601_read_word(struct i2c_client *client, int page, int phase,
return ret;
ret = i2c_smbus_read_block_data(client,
REG_PHASE_REPORTING,
- buf);
+ sizeof(buf), buf);
if (ret < 0)
return ret;
if (ret < 6)
@@ -278,7 +278,8 @@ static int max16601_get_id(struct i2c_client *client)
enum chips id;
int ret;
- ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);
+ ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID,
+ sizeof(buf) - 1, buf);
if (ret < 0 || ret < 11)
return -ENODEV;
--
2.56.0.257.gf7497c7d27-goog