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 1/2] HID: uhid: Don't send the report ID if it's zero
Date: Mon, 5 Dec 2022 13:03:53 -0800 [thread overview]
Message-ID: <20221205210354.11846-2-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20221205210354.11846-1-andrew.smirnov@gmail.com>
Report ID of zero is a special case handling ID-less reports and in
that case we should omit report ID from the payload being sent to the
backend.
Without this change UHID_DEV_NUMBERED_{FEATURE,OUTPUT}_REPORTS doesn't
represent a semantical difference.
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/uhid.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 2a918aeb0af1..7551120215e8 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -273,11 +273,11 @@ static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
}
static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
- const u8 *buf, size_t count, u8 rtype)
+ u8 *buf, size_t count, u8 rtype)
{
struct uhid_device *uhid = hid->driver_data;
struct uhid_event *ev;
- int ret;
+ int ret, skipped_report_id = 0;
if (!READ_ONCE(uhid->running) || count > UHID_DATA_MAX)
return -EIO;
@@ -286,6 +286,15 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
if (!ev)
return -ENOMEM;
+ /* Byte 0 is the report number. Report data starts at byte 1.*/
+ buf[0] = rnum;
+ if (buf[0] == 0x0) {
+ /* Don't send the Report ID */
+ buf++;
+ count--;
+ skipped_report_id = 1;
+ }
+
ev->type = UHID_SET_REPORT;
ev->u.set_report.rnum = rnum;
ev->u.set_report.rtype = rtype;
@@ -306,7 +315,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum,
if (uhid->report_buf.u.set_report_reply.err)
ret = -EIO;
else
- ret = count;
+ ret = count + skipped_report_id;
unlock:
mutex_unlock(&uhid->report_lock);
--
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 ` Andrey Smirnov [this message]
2022-12-12 15:23 ` [RFC PATCH 1/2] HID: uhid: Don't send the report ID if it's zero David Rheinsberg
2022-12-15 20:44 ` Andrey Smirnov
2022-12-05 21:03 ` [RFC PATCH 2/2] HID: usbhid: Don't include report ID zero into returned data Andrey Smirnov
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-2-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).