From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>,
Cosmo Chou <cosmo.chou@quantatw.com>,
Andy Chung <andy.chung@amd.com>,
Ninad Palsule <ninad@linux.ibm.com>,
Abdurrahman Hussain <abdurrahman@nexthop.ai>,
Robert Marko <robert.marko@sartura.hr>,
Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com>,
Daniel Nilsson <daniel.nilsson@flex.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 06/31] hwmon: (pmbus/adm1266) use 4-argument i2c_smbus_read_block_data()
Date: Sat, 24 Oct 2026 20:06:09 -0700 [thread overview]
Message-ID: <20261024-hwmon-i2c-smbus-read-block-data-v1-6-e81941ad0cd3@gmail.com> (raw)
In-Reply-To: <20261024-hwmon-i2c-smbus-read-block-data-v1-0-e81941ad0cd3@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2026-10-25 3:06 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 3:06 [PATCH 00/31] hwmon: convert i2c_smbus_read_block_data() users to pass buffer length Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 01/31] hwmon: (lineage-pem) use 4-argument i2c_smbus_read_block_data() Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 02/31] hwmon: (lm93) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 03/31] hwmon: (pt5161l) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 04/31] hwmon: (kb9002) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 05/31] hwmon: (pmbus/acbel-fsg032) " Dmitry Torokhov
2026-10-25 3:06 ` Dmitry Torokhov [this message]
2026-10-25 3:06 ` [PATCH 07/31] hwmon: (pmbus/aps-379) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 08/31] hwmon: (pmbus/bpa-rs600) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 09/31] hwmon: (pmbus/crps) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 10/31] hwmon: (pmbus/d1u74t) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 11/31] hwmon: (pmbus/dps920ab) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 12/31] hwmon: (pmbus/fsp-3y) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 13/31] hwmon: (pmbus/ibm-cffps) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 14/31] hwmon: (pmbus/inspur-ipsps) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 15/31] hwmon: (pmbus/ir35221) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 16/31] hwmon: (pmbus/lt7182s) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 17/31] hwmon: (pmbus/ltc4286) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 18/31] hwmon: (pmbus/lx1308) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 19/31] hwmon: (pmbus/max15301) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 20/31] hwmon: (pmbus/max16601) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 21/31] hwmon: (pmbus/max20730) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 22/31] hwmon: (pmbus/mp5920) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 23/31] hwmon: (pmbus/pim4328) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 24/31] hwmon: (pmbus) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 25/31] hwmon: (pmbus/pxe1610) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 26/31] hwmon: (pmbus/q54sj108a2) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 27/31] hwmon: (pmbus/stpddc60) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 28/31] hwmon: (pmbus/tps53679) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 29/31] hwmon: (pmbus/ucd9000) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 30/31] hwmon: (pmbus/ucd9200) " Dmitry Torokhov
2026-10-25 3:06 ` [PATCH 31/31] hwmon: (pmbus/zl6100) " Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261024-hwmon-i2c-smbus-read-block-data-v1-6-e81941ad0cd3@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=Delphine_CC_Chiu@Wiwynn.com \
--cc=abdurrahman@nexthop.ai \
--cc=andy.chung@amd.com \
--cc=cosmo.chou@quantatw.com \
--cc=daniel.nilsson@flex.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=ninad@linux.ibm.com \
--cc=robert.marko@sartura.hr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®