[PATCH 01/31] hwmon: (lineage-pem) use 4-argument i2c_smbus_read_block_data()
From: Dmitry Torokhov
Date: Sat Oct 24 2026 - 23:07:50 EST
Pass the expected data length and destination buffer directly to
i2c_smbus_read_block_data() instead of copying through an intermediate
buffer.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hwmon/lineage-pem.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/hwmon/lineage-pem.c b/drivers/hwmon/lineage-pem.c
index 2553e49f8401..75a44b0639dc 100644
--- a/drivers/hwmon/lineage-pem.c
+++ b/drivers/hwmon/lineage-pem.c
@@ -130,20 +130,15 @@ struct pem_data {
static int pem_read_block(struct i2c_client *client, u8 command, u8 *data,
int data_len)
{
- u8 block_buffer[I2C_SMBUS_BLOCK_MAX];
int result;
- result = i2c_smbus_read_block_data(client, command, block_buffer);
+ result = i2c_smbus_read_block_data(client, command, data_len, data);
if (unlikely(result < 0))
- goto abort;
- if (unlikely(result == 0xff || result != data_len)) {
- result = -EIO;
- goto abort;
- }
- memcpy(data, block_buffer, data_len);
- result = 0;
-abort:
- return result;
+ return result;
+ if (unlikely(result == 0xff || result != data_len))
+ return -EIO;
+
+ return 0;
}
static struct pem_data *pem_update_device(struct device *dev)
--
2.56.0.257.gf7497c7d27-goog