From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>,
David Rheinsberg <david.rheinsberg@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [RFC PATCH 2/2] HID: usbhid: Don't include report ID zero into returned data
Date: Mon, 5 Dec 2022 13:03:54 -0800 [thread overview]
Message-ID: <20221205210354.11846-3-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20221205210354.11846-1-andrew.smirnov@gmail.com>
Report ID of zero is a special case for ID-less reports, which by
definition do not have report ID as a part of their payload. Not
returning an extra zero also matches hidraw documentation,
specifically:
For devices which do not use numbered reports, set the first
byte to 0. The returned report buffer will contain the report
number in the first byte, followed by the report data read from
the device. For devices which do not use numbered reports, the
report data will begin at the first byte of the returned buffer.
Cc: David Rheinsberg <david.rheinsberg@gmail.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/hid/usbhid/hid-core.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index be4c731aaa65..575f09003602 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -874,18 +874,8 @@ static int usbhid_get_raw_report(struct hid_device *hid,
struct usb_device *dev = hid_to_usb_dev(hid);
struct usb_interface *intf = usbhid->intf;
struct usb_host_interface *interface = intf->cur_altsetting;
- int skipped_report_id = 0;
int ret;
- /* Byte 0 is the report number. Report data starts at byte 1.*/
- buf[0] = report_number;
- if (report_number == 0x0) {
- /* Offset the return buffer by 1, so that the report ID
- will remain in byte 0. */
- buf++;
- count--;
- skipped_report_id = 1;
- }
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
HID_REQ_GET_REPORT,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
@@ -893,10 +883,6 @@ static int usbhid_get_raw_report(struct hid_device *hid,
interface->desc.bInterfaceNumber, buf, count,
USB_CTRL_SET_TIMEOUT);
- /* count also the report id */
- if (ret > 0 && skipped_report_id)
- ret++;
-
return ret;
}
--
2.34.1
next prev parent reply other threads:[~2022-12-05 21:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 21:03 [RFC PATCH 0/2] Handling of non-numbered feature reports by hidraw Andrey Smirnov
2022-12-05 21:03 ` [RFC PATCH 1/2] HID: uhid: Don't send the report ID if it's zero Andrey Smirnov
2022-12-12 15:23 ` David Rheinsberg
2022-12-15 20:44 ` Andrey Smirnov
2022-12-05 21:03 ` Andrey Smirnov [this message]
2022-12-08 15:46 ` [RFC PATCH 0/2] Handling of non-numbered feature reports by hidraw David Rheinsberg
2022-12-08 20:58 ` Andrey Smirnov
2022-12-12 15:24 ` David Rheinsberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221205210354.11846-3-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=david.rheinsberg@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).