lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260206163153.130026-1-romain.sioen@microchip.com>
Date: Fri, 6 Feb 2026 17:31:53 +0100
From: Romain Sioen <romain.sioen@...rochip.com>
To: <linux-kernel@...r.kernel.org>
CC: <gupt21@...il.com>, <jikos@...nel.org>, <marius.cristea@...rochip.com>,
	Romain Sioen <romain.sioen@...rochip.com>
Subject: [PATCH] HID: mcp2221: use mcp_i2c_smbus_read for block reads

Refactor mcp_smbus_xfer() to use the mcp_i2c_smbus_read() helper function
for I2C_SMBUS_BLOCK_DATA and I2C_SMBUS_I2C_BLOCK_DATA read operations.

This replaces the manual setup of the receive buffer and explicit calls
to mcp_send_data_req_status(), making the code cleaner and more consistent
with other read paths in the driver.

Signed-off-by: Romain Sioen <romain.sioen@...rochip.com>
Signed-off-by: Marius Cristea <marius.cristea@...rochip.com>
---
 drivers/hid/hid-mcp2221.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index 33603b019f975..64dcedbcc0fc9 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -534,10 +534,10 @@ static int mcp_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
 			if (ret)
 				goto exit;
 
-			mcp->rxbuf_idx = 0;
-			mcp->rxbuf = data->block;
-			mcp->txbuf[0] = MCP2221_I2C_GET_DATA;
-			ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
+			ret = mcp_i2c_smbus_read(mcp, NULL,
+						MCP2221_I2C_RD_RPT_START,
+						addr, data->block[0] + 1,
+						data->block);
 			if (ret)
 				goto exit;
 		} else {
@@ -553,14 +553,14 @@ static int mcp_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
 	case I2C_SMBUS_I2C_BLOCK_DATA:
 		if (read_write == I2C_SMBUS_READ) {
 			ret = mcp_smbus_write(mcp, addr, command, NULL,
-						0, MCP2221_I2C_WR_NO_STOP, 1);
+						0, MCP2221_I2C_WR_NO_STOP, 0);
 			if (ret)
 				goto exit;
 
-			mcp->rxbuf_idx = 0;
-			mcp->rxbuf = data->block;
-			mcp->txbuf[0] = MCP2221_I2C_GET_DATA;
-			ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
+			ret = mcp_i2c_smbus_read(mcp, NULL,
+						MCP2221_I2C_RD_RPT_START,
+						addr, data->block[0],
+						&data->block[1]);
 			if (ret)
 				goto exit;
 		} else {
-- 
2.53.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ