2010-06-30 13:51:04

by Alan Ott

[permalink] [raw]
Subject: [PATCH 1/1] HID: Send Report ID when numbered reports are sent over the control endpoint.

The Report ID wasn't sent as part of the payload for reports which were sent
over the control endpoint. This is required by section 8.1 of the HID spec.

Signed-off-by: Alan Ott <[email protected]>
---
drivers/hid/usbhid/hid-core.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index deef816..1697687 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -854,14 +854,21 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
ret++;
}
} else {
+ int skipped_report_id = 0;
+ if (buf[0] == 0x0) {
+ /* Don't send the Report ID */
+ buf++;
+ count--;
+ skipped_report_id = 1;
+ }
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
HID_REQ_SET_REPORT,
USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
((report_type + 1) << 8) | *buf,
- interface->desc.bInterfaceNumber, buf + 1, count - 1,
+ interface->desc.bInterfaceNumber, buf, count,
USB_CTRL_SET_TIMEOUT);
- /* count also the report id */
- if (ret > 0)
+ /* count also the report id, if this was a numbered report. */
+ if (ret > 0 && skipped_report_id)
ret++;
}

--
1.7.0.4


2010-07-11 21:14:08

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH 1/1] HID: Send Report ID when numbered reports are sent over the control endpoint.

On Wed, 30 Jun 2010, Alan Ott wrote:

> The Report ID wasn't sent as part of the payload for reports which were sent
> over the control endpoint. This is required by section 8.1 of the HID spec.

We already have a8ab5d58b0238b8199cc699b8dff7c5e1da24138 commit in Linus'
tree, so I'll take this for .35 still, thanks a lot for fixing it Alan.

>
> Signed-off-by: Alan Ott <[email protected]>
> ---
> drivers/hid/usbhid/hid-core.c | 13 ++++++++++---
> 1 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> index deef816..1697687 100644
> --- a/drivers/hid/usbhid/hid-core.c
> +++ b/drivers/hid/usbhid/hid-core.c
> @@ -854,14 +854,21 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
> ret++;
> }
> } else {
> + int skipped_report_id = 0;
> + if (buf[0] == 0x0) {
> + /* Don't send the Report ID */
> + buf++;
> + count--;
> + skipped_report_id = 1;
> + }
> ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
> HID_REQ_SET_REPORT,
> USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
> ((report_type + 1) << 8) | *buf,
> - interface->desc.bInterfaceNumber, buf + 1, count - 1,
> + interface->desc.bInterfaceNumber, buf, count,
> USB_CTRL_SET_TIMEOUT);
> - /* count also the report id */
> - if (ret > 0)
> + /* count also the report id, if this was a numbered report. */
> + if (ret > 0 && skipped_report_id)
> ret++;
> }

--
Jiri Kosina
SUSE Labs, Novell Inc.