Skip to content

Commit 079e60a

Browse files
passgatdtor
authored andcommitted
Input: edt-ft5x06 - unify the crc check
With this patch, the CRC is always verified by the same function, even in the case of accessing registers where the number of bytes is minimal. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Link: https://lore.kernel.org/r/20230402200951.1032513-9-dario.binacchi@amarulasolutions.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 9dfd970 commit 079e60a

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

drivers/input/touchscreen/edt-ft5x06.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,10 @@ static int edt_M06_i2c_read(void *context, const void *reg_buf, size_t reg_size,
240240
if (!edt_ft5x06_ts_check_crc(tsdata, val_buf, val_size))
241241
return -EIO;
242242
} else if (reg_read) {
243-
u8 crc = wbuf[0] ^ wbuf[1] ^ rbuf[0];
244-
245-
if (crc != rbuf[1]) {
246-
dev_err(dev, "crc error: 0x%02x expected, got 0x%02x\n",
247-
crc, rbuf[1]);
243+
wbuf[2] = rbuf[0];
244+
wbuf[3] = rbuf[1];
245+
if (!edt_ft5x06_ts_check_crc(tsdata, wbuf, 4))
248246
return -EIO;
249-
}
250247

251248
*((u8 *)val_buf) = rbuf[0];
252249
}

0 commit comments

Comments
 (0)