Message ID | 20200508055656.96389-5-jiada_wang@mentor.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | atmel_mxt_ts misc | expand |
Hi Jiada, Nick, On Thu, May 07, 2020 at 10:56:04PM -0700, Jiada Wang wrote: > From: Nick Dyer <nick.dyer@itdev.co.uk> > > On some firmware variants, the size of the info block exceeds what can > be read in a single transfer. Is this limitation of the mXT controller or maybe it is issue with implementation of the particular i2c adapter and should be dealt with there? Thanks.
Hello Dmitry On 2020/05/12 7:19, Dmitry Torokhov wrote: > Hi Jiada, Nick, > > On Thu, May 07, 2020 at 10:56:04PM -0700, Jiada Wang wrote: >> From: Nick Dyer <nick.dyer@itdev.co.uk> >> >> On some firmware variants, the size of the info block exceeds what can >> be read in a single transfer. > > Is this limitation of the mXT controller or maybe it is issue with > implementation of the particular i2c adapter and should be dealt with > there? > This patch was authored by Nick, but I assume it is trying to address issue due to I2C adapter limitation which following patch in this series is already doing "Input: atmel_mxt_ts: Limit the max bytes transferred in an i2c transaction" I will extend patch "Input: atmel_mxt_ts: Limit the max bytes transferred in an i2c transaction" to also cover this case. Thanks, Jiada > Thanks. >
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 3f1ebe14802f..7e6a66e3e1e0 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -40,7 +40,7 @@ #define MXT_OBJECT_START 0x07 #define MXT_OBJECT_SIZE 6 #define MXT_INFO_CHECKSUM_SIZE 3 -#define MXT_MAX_BLOCK_WRITE 256 +#define MXT_MAX_BLOCK_WRITE 255 /* Object types */ #define MXT_DEBUG_DIAGNOSTIC_T37 37 @@ -624,8 +624,8 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock) return 0; } -static int __mxt_read_reg(struct i2c_client *client, - u16 reg, u16 len, void *val) +static int __mxt_read_chunk(struct i2c_client *client, + u16 reg, u16 len, void *val) { struct i2c_msg xfer[2]; u8 buf[2]; @@ -659,6 +659,28 @@ static int __mxt_read_reg(struct i2c_client *client, return ret; } +static int __mxt_read_reg(struct i2c_client *client, + u16 reg, u16 len, void *buf) +{ + u16 offset = 0; + int error; + u16 size; + + while (offset < len) { + size = min(MXT_MAX_BLOCK_WRITE, len - offset); + + error = __mxt_read_chunk(client, + reg + offset, + size, buf + offset); + if (error) + return error; + + offset += size; + } + + return 0; +} + static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, const void *val) {