From ce414fb127d9a0bf566502023a8030af564f66bb Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 22 Jun 2026 22:35:44 -0700 Subject: [PATCH] Input: mms114 - use appropriate register argument types The MMS114 I2C touch controller uses 8-bit register addresses (0x01 to 0xF2) and 8-bit single-register data values. The helper functions previously declared reg and val as 32-bit unsigned int, requiring explicit bitwise masking (& 0xff) to narrow the values down to u8 before populating the I2C transfer buffers. Update reg and val parameters to u8 across mms114_read_reg(), mms114_write_reg(), and __mms114_read_reg() to accurately reflect the hardware specification and eliminate the redundant & 0xff masking. Additionally, update the val buffer pointer in __mms114_read_reg() from u8 * to void * to allow callers to pass data structures directly without requiring explicit casting. Assisted-by: Antigravity:gemini-3.5-flash Link: https://patch.msgid.link/20260616050912.1531241-3-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/mms114.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index db23b51f4630..c2e006ac1196 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -87,12 +87,12 @@ struct mms114_touch { u8 reserved[2]; } __packed; -static int __mms114_read_reg(struct mms114_data *data, unsigned int reg, - unsigned int len, u8 *val) +static int __mms114_read_reg(struct mms114_data *data, u8 reg, + unsigned int len, void *val) { struct i2c_client *client = data->client; struct i2c_msg xfer[2]; - u8 buf = reg & 0xff; + u8 buf = reg; int error; if (reg <= MMS114_MODE_CONTROL && reg + len > MMS114_MODE_CONTROL) @@ -121,7 +121,7 @@ static int __mms114_read_reg(struct mms114_data *data, unsigned int reg, return 0; } -static int mms114_read_reg(struct mms114_data *data, unsigned int reg) +static int mms114_read_reg(struct mms114_data *data, u8 reg) { u8 val; int error; @@ -133,15 +133,14 @@ static int mms114_read_reg(struct mms114_data *data, unsigned int reg) return error < 0 ? error : val; } -static int mms114_write_reg(struct mms114_data *data, unsigned int reg, - unsigned int val) +static int mms114_write_reg(struct mms114_data *data, u8 reg, u8 val) { struct i2c_client *client = data->client; u8 buf[2]; int error; - buf[0] = reg & 0xff; - buf[1] = val & 0xff; + buf[0] = reg; + buf[1] = val; error = i2c_master_send(client, buf, 2); if (error != 2) { @@ -242,9 +241,8 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id) touch_size = packet_size / event_size; - error = __mms114_read_reg(data, MMS114_INFORMATION, packet_size, - (u8 *)touch); - if (error < 0) + error = __mms114_read_reg(data, MMS114_INFORMATION, packet_size, touch); + if (error) goto out; for (index = 0; index < touch_size; index++) {