Message ID | 20190816082952.17985-5-jiada_wang@mentor.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | atmel_mxt_ts misc | expand |
On Fri, Aug 16, 2019 at 05:28:53PM +0900, 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. > > Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> > (cherry picked from ndyer/linux/for-upstream commit 74c4f5277cfa403d43fafc404119dc57a08677db) > [gdavis: Forward port and fix conflicts due to v4.14.51 commit > 960fe000b1d3 ("Input: atmel_mxt_ts - fix the firmware > update").] > Signed-off-by: George G. Davis <george_davis@mentor.com> > Signed-off-by: Jiada Wang <jiada_wang@mentor.com> > --- > drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > index 9b165d23e092..2d70ddf71cd9 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 > @@ -659,6 +659,27 @@ static int __mxt_read_reg(struct i2c_client *client, > return ret; > } > > +static int mxt_read_blks(struct mxt_data *data, u16 start, u16 count, u8 *buf) Can we call this __mxt_read_reg() and the original read reg call __mxt_read_chunk()? > +{ > + u16 offset = 0; > + int error; > + u16 size; > + > + while (offset < count) { > + size = min(MXT_MAX_BLOCK_WRITE, count - offset); > + > + error = __mxt_read_reg(data->client, > + start + offset, > + size, buf + offset); > + if (error) > + return error; > + > + offset += size; > + } > + > + return 0; > +} Thanks.
Hi Dmitry On 2019/08/17 2:18, Dmitry Torokhov wrote: > On Fri, Aug 16, 2019 at 05:28:53PM +0900, 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. >> >> Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> >> (cherry picked from ndyer/linux/for-upstream commit 74c4f5277cfa403d43fafc404119dc57a08677db) >> [gdavis: Forward port and fix conflicts due to v4.14.51 commit >> 960fe000b1d3 ("Input: atmel_mxt_ts - fix the firmware >> update").] >> Signed-off-by: George G. Davis <george_davis@mentor.com> >> Signed-off-by: Jiada Wang <jiada_wang@mentor.com> >> --- >> drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++++--- >> 1 file changed, 24 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c >> index 9b165d23e092..2d70ddf71cd9 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 >> @@ -659,6 +659,27 @@ static int __mxt_read_reg(struct i2c_client *client, >> return ret; >> } >> >> +static int mxt_read_blks(struct mxt_data *data, u16 start, u16 count, u8 *buf) > > Can we call this __mxt_read_reg() and the original read reg call > __mxt_read_chunk()? > yes, I will update in v2 patch-set, so that every call to __mxt_read_reg() in atmel driver, can have the feature to split large size transfer. Thanks, Jiada >> +{ >> + u16 offset = 0; >> + int error; >> + u16 size; >> + >> + while (offset < count) { >> + size = min(MXT_MAX_BLOCK_WRITE, count - offset); >> + >> + error = __mxt_read_reg(data->client, >> + start + offset, >> + size, buf + offset); >> + if (error) >> + return error; >> + >> + offset += size; >> + } >> + >> + return 0; >> +} > > Thanks. >
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 9b165d23e092..2d70ddf71cd9 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 @@ -659,6 +659,27 @@ static int __mxt_read_reg(struct i2c_client *client, return ret; } +static int mxt_read_blks(struct mxt_data *data, u16 start, u16 count, u8 *buf) +{ + u16 offset = 0; + int error; + u16 size; + + while (offset < count) { + size = min(MXT_MAX_BLOCK_WRITE, count - offset); + + error = __mxt_read_reg(data->client, + start + 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) { @@ -1793,7 +1814,7 @@ static int mxt_read_info_block(struct mxt_data *data) id_buf = buf; /* Read rest of info block */ - error = __mxt_read_reg(client, MXT_OBJECT_START, + error = mxt_read_blks(data, MXT_OBJECT_START, size - MXT_OBJECT_START, id_buf + MXT_OBJECT_START); if (error) @@ -2783,7 +2804,7 @@ static ssize_t mxt_object_show(struct device *dev, u16 size = mxt_obj_size(object); u16 addr = object->start_address + j * size; - error = __mxt_read_reg(data->client, addr, size, obuf); + error = mxt_read_blks(data, addr, size, obuf); if (error) goto done;