[PATCH 06/31] hwmon: (pmbus/adm1266) use 4-argument i2c_smbus_read_block_data()

From: Dmitry Torokhov

Date: Sat Oct 24 2026 - 23:08:12 EST


Pass the buffer size to i2c_smbus_read_block_data() and shrink the
GPIO read buffers to I2C_SMBUS_BLOCK_MAX since they contain raw binary
status bytes and are not NUL-terminated.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hwmon/pmbus/adm1266.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
index 22ccb721dd51..9f3b5bc9f3e2 100644
--- a/drivers/hwmon/pmbus/adm1266.c
+++ b/drivers/hwmon/pmbus/adm1266.c
@@ -165,7 +165,7 @@ static const char *adm1266_names[ADM1266_GPIO_NR + ADM1266_PDIO_NR] = {
static int adm1266_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct adm1266_data *data = gpiochip_get_data(chip);
- u8 read_buf[I2C_SMBUS_BLOCK_MAX + 1];
+ u8 read_buf[I2C_SMBUS_BLOCK_MAX];
unsigned long pins_status;
unsigned int pmbus_cmd;
int ret;
@@ -177,7 +177,8 @@ static int adm1266_gpio_get(struct gpio_chip *chip, unsigned int offset)

guard(pmbus_lock)(data->client);

- ret = i2c_smbus_read_block_data(data->client, pmbus_cmd, read_buf);
+ ret = i2c_smbus_read_block_data(data->client, pmbus_cmd,
+ sizeof(read_buf), read_buf);
if (ret < 0)
return ret;
if (ret < 2)
@@ -194,14 +195,15 @@ static int adm1266_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask
unsigned long *bits)
{
struct adm1266_data *data = gpiochip_get_data(chip);
- u8 read_buf[ADM1266_PMBUS_BLOCK_MAX + 1];
+ u8 read_buf[I2C_SMBUS_BLOCK_MAX];
unsigned long status;
unsigned int gpio_nr;
int ret;

guard(pmbus_lock)(data->client);

- ret = i2c_smbus_read_block_data(data->client, ADM1266_GPIO_STATUS, read_buf);
+ ret = i2c_smbus_read_block_data(data->client, ADM1266_GPIO_STATUS,
+ sizeof(read_buf), read_buf);
if (ret < 0)
return ret;
if (ret < 2)
@@ -215,7 +217,8 @@ static int adm1266_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask
set_bit(gpio_nr, bits);
}

- ret = i2c_smbus_read_block_data(data->client, ADM1266_PDIO_STATUS, read_buf);
+ ret = i2c_smbus_read_block_data(data->client, ADM1266_PDIO_STATUS,
+ sizeof(read_buf), read_buf);
if (ret < 0)
return ret;
if (ret < 2)
@@ -361,7 +364,8 @@ static int adm1266_firmware_revision_read(struct seq_file *s, void *pdata)
int ret;

guard(pmbus_lock)(client);
- ret = i2c_smbus_read_block_data(client, ADM1266_IC_DEVICE_REV, buf);
+ ret = i2c_smbus_read_block_data(client, ADM1266_IC_DEVICE_REV,
+ sizeof(buf), buf);
if (ret < 0)
return ret;
if (ret < 3)
@@ -387,7 +391,8 @@ static int adm1266_powerup_counter_read(struct seq_file *s, void *pdata)
int ret;

guard(pmbus_lock)(client);
- ret = i2c_smbus_read_block_data(client, ADM1266_POWERUP_COUNTER, buf);
+ ret = i2c_smbus_read_block_data(client, ADM1266_POWERUP_COUNTER,
+ sizeof(buf), buf);
if (ret < 0)
return ret;
if (ret != 2)
@@ -461,7 +466,8 @@ static int adm1266_rtc_get(void *data, u64 *val)
int ret, i;

guard(pmbus_lock)(client);
- ret = i2c_smbus_read_block_data(client, ADM1266_SET_RTC, buf);
+ ret = i2c_smbus_read_block_data(client, ADM1266_SET_RTC,
+ sizeof(buf), buf);
if (ret < 0)
return ret;
if (ret < 6)
@@ -525,7 +531,8 @@ static int adm1266_nvmem_read_blackbox(struct adm1266_data *data, u8 *read_buff)
u8 buf[I2C_SMBUS_BLOCK_MAX];
int ret;

- ret = i2c_smbus_read_block_data(data->client, ADM1266_BLACKBOX_INFO, buf);
+ ret = i2c_smbus_read_block_data(data->client, ADM1266_BLACKBOX_INFO,
+ sizeof(buf), buf);
if (ret < 0)
return ret;


--
2.56.0.257.gf7497c7d27-goog