linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

^ 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
  2015-07-08  9:15   ` Jiri Kosina
  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

* Re: [PATCH] HID: cp2112: fix to force single data-report reply
  2015-07-01  8:05 ` Ellen Wang
@ 2015-07-08  9:15   ` Jiri Kosina
  2015-07-08 10:24     ` Ellen Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2015-07-08  9:15 UTC (permalink / raw)
  To: Ellen Wang; +Cc: Antonio Borneo, linux-input, linux-kernel, linux-i2c

On Wed, 1 Jul 2015, Ellen Wang wrote:

> 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.

Ellen, are you okay with me applying the patch with

	Tested-by: Ellen Wang <ellen@cumulusnetworks.com>

?

Thanks,

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: cp2112: fix to force single data-report reply
  2015-07-08  9:15   ` Jiri Kosina
@ 2015-07-08 10:24     ` Ellen Wang
  2015-07-08 10:41       ` Jiri Kosina
  0 siblings, 1 reply; 6+ messages in thread
From: Ellen Wang @ 2015-07-08 10:24 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Antonio Borneo, linux-input, linux-kernel, linux-i2c

On 07/08/2015 02:15 AM, Jiri Kosina wrote:
> On Wed, 1 Jul 2015, Ellen Wang wrote:
>
>> 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.
>
> Ellen, are you okay with me applying the patch with
>
> 	Tested-by: Ellen Wang <ellen@cumulusnetworks.com>
>
> ?
>
> Thanks,

Yes.  Thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: cp2112: fix to force single data-report reply
  2015-07-08 10:24     ` Ellen Wang
@ 2015-07-08 10:41       ` Jiri Kosina
  2015-07-11 11:48         ` Antonio Borneo
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2015-07-08 10:41 UTC (permalink / raw)
  To: Ellen Wang; +Cc: Antonio Borneo, linux-input, linux-kernel, linux-i2c

On Wed, 8 Jul 2015, Ellen Wang wrote:

> > > 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.
> > 
> > Ellen, are you okay with me applying the patch with
> > 
> > 	Tested-by: Ellen Wang <ellen@cumulusnetworks.com>
> > 
> > ?
> > 
> > Thanks,
> 
> Yes.  Thank you.

Ammended with Cc: stable tag, and applied to for-4.2/upstream-fixes. 
Thanks,

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: cp2112: fix to force single data-report reply
  2015-07-08 10:41       ` Jiri Kosina
@ 2015-07-11 11:48         ` Antonio Borneo
  0 siblings, 0 replies; 6+ messages in thread
From: Antonio Borneo @ 2015-07-11 11:48 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Ellen Wang, linux-input, linux-kernel, linux-i2c

On Wed, Jul 8, 2015 at 6:41 PM, Jiri Kosina <jkosina@suse.com> wrote:
> On Wed, 8 Jul 2015, Ellen Wang wrote:
>
>> > > 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.
>> >
>> > Ellen, are you okay with me applying the patch with
>> >
>> >     Tested-by: Ellen Wang <ellen@cumulusnetworks.com>
>> >
>> > ?
>> >
>> > Thanks,
>>
>> Yes.  Thank you.
>
> Ammended with Cc: stable tag, and applied to for-4.2/upstream-fixes.
> Thanks,

Thanks!

Antonio

^ 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
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).