* [PATCH] HID: cp2112: fix to force single data-report reply
@ 2015-06-21  6:20 Antonio Borneo
  2015-07-01  8:05 ` Ellen Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Antonio Borneo @ 2015-06-21  6:20 UTC (permalink / raw)
  To: Jiri Kosina, linux-input
  Cc: Antonio Borneo, linux-kernel, linux-i2c, Ellen Wang
Current implementation of cp2112_raw_event() only accepts one data
report at a time. If last received data report is not fully handled
yet, a new incoming data report will overwrite it. In such case we
don't guaranteed to propagate the correct incoming data.
The trivial fix implemented here forces a single report at a time
by requesting in cp2112_read() no more than 61 byte of data, which
is the payload size of a single data report.
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
---
Hi Jiri,
I think this should go through linux-stable.
Thanks,
Antonio
 drivers/hid/hid-cp2112.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 3318de6..a2dbbbe 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -356,6 +356,8 @@ static int cp2112_read(struct cp2112_device *dev, u8 *data, size_t size)
 	struct cp2112_force_read_report report;
 	int ret;
 
+	if (size > sizeof(dev->read_data))
+		size = sizeof(dev->read_data);
 	report.report = CP2112_DATA_READ_FORCE_SEND;
 	report.length = cpu_to_be16(size);
 
-- 
2.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
^ permalink raw reply related	[flat|nested] 6+ messages in thread
* Re: [PATCH] HID: cp2112: fix to force single data-report reply
  2015-06-21  6:20 [PATCH] HID: cp2112: fix to force single data-report reply Antonio Borneo
@ 2015-07-01  8:05 ` Ellen Wang
       [not found]   ` <55939F3E.7070505-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Ellen Wang @ 2015-07-01  8:05 UTC (permalink / raw)
  To: Antonio Borneo, Jiri Kosina, linux-input; +Cc: linux-kernel, linux-i2c
Works as described.  Thank you!
By the way, I tested the code with and without your fix on my rev 2 
chip, and it behaved the same way as you describe on your rev 1 chip.
On 06/20/2015 11:20 PM, Antonio Borneo wrote:
> Current implementation of cp2112_raw_event() only accepts one data
> report at a time. If last received data report is not fully handled
> yet, a new incoming data report will overwrite it. In such case we
> don't guaranteed to propagate the correct incoming data.
>
> The trivial fix implemented here forces a single report at a time
> by requesting in cp2112_read() no more than 61 byte of data, which
> is the payload size of a single data report.
>
> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
> ---
>
> Hi Jiri,
>
> I think this should go through linux-stable.
>
> Thanks,
> Antonio
>
>   drivers/hid/hid-cp2112.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
> index 3318de6..a2dbbbe 100644
> --- a/drivers/hid/hid-cp2112.c
> +++ b/drivers/hid/hid-cp2112.c
> @@ -356,6 +356,8 @@ static int cp2112_read(struct cp2112_device *dev, u8 *data, size_t size)
>   	struct cp2112_force_read_report report;
>   	int ret;
>
> +	if (size > sizeof(dev->read_data))
> +		size = sizeof(dev->read_data);
>   	report.report = CP2112_DATA_READ_FORCE_SEND;
>   	report.length = cpu_to_be16(size);
>
>
^ permalink raw reply	[flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-07-11 11:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-21  6:20 [PATCH] HID: cp2112: fix to force single data-report reply Antonio Borneo
2015-07-01  8:05 ` Ellen Wang
     [not found]   ` <55939F3E.7070505-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-07-08  9:15     ` Jiri Kosina
2015-07-08 10:24       ` Ellen Wang
2015-07-08 10:41         ` Jiri Kosina
2015-07-11 11:48           ` Antonio Borneo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).