From: Benjamin Tissoires <bentiss@kernel.org>
To: Jiri Kosina <jikos@kernel.org>,
Peter Hutterer <peter.hutterer@who-t.net>,
Vicki Pfau <vi@endrift.com>, Shuah Khan <shuah@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
Benjamin Tissoires <bentiss@kernel.org>
Subject: [PATCH HID v2 10/11] HID: add quirk to prevent hid-input to be used
Date: Tue, 10 Sep 2024 23:43:46 +0900 [thread overview]
Message-ID: <20240910-hid-bpf-hid-generic-v2-10-083dfc189e97@kernel.org> (raw)
In-Reply-To: <20240910-hid-bpf-hid-generic-v2-0-083dfc189e97@kernel.org>
This is useful when you want to handle the device entirely from BPF
without exposing the automatic input nodes.
This is useful in case we want to have a third party program that directly
talks to the hidraw node and we don't want regular input events to be
emitted. This third party program can load a BPF program that instructs
hid-generic to rebind on the device with hidraw only and then open the
hidraw node itself.
When the application is closed, the BPF program is unloaded and the normal
driver takes back the control of the device.
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
changes in v2:
- rely on hdev->quirks instead of a new struct
---
drivers/hid/hid-core.c | 2 ++
include/linux/hid.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index bf63e2819baf..35cefd7167aa 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2217,6 +2217,8 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE)
connect_mask |= HID_CONNECT_HIDINPUT_FORCE;
+ if (hdev->quirks & HID_QUIRK_IGNORE_HIDINPUT)
+ connect_mask &= ~HID_CONNECT_HIDINPUT;
if (hdev->bus != BUS_USB)
connect_mask &= ~HID_CONNECT_HIDDEV;
if (hid_hiddev(hdev))
diff --git a/include/linux/hid.h b/include/linux/hid.h
index b3a9586363c9..b6bad03649f6 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -360,6 +360,7 @@ struct hid_item {
* | @HID_QUIRK_HAVE_SPECIAL_DRIVER:
* | @HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE:
* | @HID_QUIRK_IGNORE_SPECIAL_DRIVER
+ * | @HID_QUIRK_IGNORE_HIDINPUT
* | @HID_QUIRK_FULLSPEED_INTERVAL:
* | @HID_QUIRK_NO_INIT_REPORTS:
* | @HID_QUIRK_NO_IGNORE:
@@ -386,6 +387,7 @@ struct hid_item {
#define HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE BIT(20)
#define HID_QUIRK_NOINVERT BIT(21)
#define HID_QUIRK_IGNORE_SPECIAL_DRIVER BIT(22)
+#define HID_QUIRK_IGNORE_HIDINPUT BIT(23)
#define HID_QUIRK_FULLSPEED_INTERVAL BIT(28)
#define HID_QUIRK_NO_INIT_REPORTS BIT(29)
#define HID_QUIRK_NO_IGNORE BIT(30)
--
2.46.0
next prev parent reply other threads:[~2024-09-10 14:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 14:43 [PATCH HID v2 00/11] HID: bpf: add a new hook to control hid-generic Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 01/11] HID: bpf: move HID-BPF report descriptor fixup earlier Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 02/11] HID: core: save one kmemdup during .probe() Benjamin Tissoires
2024-09-12 6:10 ` Peter Hutterer
2024-09-10 14:43 ` [PATCH HID v2 03/11] HID: core: remove one more kmemdup on .probe() Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 04/11] HID: bpf: allow write access to quirks field in struct hid_device Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 05/11] selftests/hid: add dependency on hid_common.h Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 06/11] selftests/hid: cleanup C tests by adding a common struct uhid_device Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 07/11] selftests/hid: allow to parametrize bus/vid/pid/rdesc on the test device Benjamin Tissoires
2024-09-10 14:43 ` [PATCH HID v2 08/11] HID: add per device quirk to force bind to hid-generic Benjamin Tissoires
2024-09-12 6:13 ` Peter Hutterer
2024-09-10 14:43 ` [PATCH HID v2 09/11] selftests/hid: add test for assigning a given device " Benjamin Tissoires
2024-09-10 14:43 ` Benjamin Tissoires [this message]
2024-09-10 14:43 ` [PATCH HID v2 11/11] selftests/hid: add test to disable hid-input Benjamin Tissoires
2024-09-13 13:38 ` (subset) [PATCH HID v2 00/11] HID: bpf: add a new hook to control hid-generic Benjamin Tissoires
2024-09-13 13:47 ` Benjamin Tissoires
2024-09-14 5:26 ` Benjamin Tissoires
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=20240910-hid-bpf-hid-generic-v2-10-083dfc189e97@kernel.org \
--to=bentiss@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=shuah@kernel.org \
--cc=vi@endrift.com \
/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).