Skip to content

Commit 645c224

Browse files
author
Benjamin Tissoires
committed
HID: add per device quirk to force bind to hid-generic
We already have the possibility to force not binding to hid-generic and rely on a dedicated driver, but we couldn't do the other way around. This is useful for BPF programs where we are fixing the report descriptor and the events, but want to avoid a specialized driver to come after BPF which would unwind everything that is done there. Reviewed-by: Peter Hutterer <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 72c5547 commit 645c224

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

drivers/hid/hid-core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,9 +2698,10 @@ static bool hid_check_device_match(struct hid_device *hdev,
26982698
/*
26992699
* hid-generic implements .match(), so we must be dealing with a
27002700
* different HID driver here, and can simply check if
2701-
* hid_ignore_special_drivers is set or not.
2701+
* hid_ignore_special_drivers or HID_QUIRK_IGNORE_SPECIAL_DRIVER
2702+
* are set or not.
27022703
*/
2703-
return !hid_ignore_special_drivers;
2704+
return !hid_ignore_special_drivers && !(hdev->quirks & HID_QUIRK_IGNORE_SPECIAL_DRIVER);
27042705
}
27052706

27062707
static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv)

drivers/hid/hid-generic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ static bool hid_generic_match(struct hid_device *hdev,
4040
if (ignore_special_driver)
4141
return true;
4242

43+
if (hdev->quirks & HID_QUIRK_IGNORE_SPECIAL_DRIVER)
44+
return true;
45+
4346
if (hdev->quirks & HID_QUIRK_HAVE_SPECIAL_DRIVER)
4447
return false;
4548

include/linux/hid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ struct hid_item {
359359
* | @HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP:
360360
* | @HID_QUIRK_HAVE_SPECIAL_DRIVER:
361361
* | @HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE:
362+
* | @HID_QUIRK_IGNORE_SPECIAL_DRIVER
362363
* | @HID_QUIRK_FULLSPEED_INTERVAL:
363364
* | @HID_QUIRK_NO_INIT_REPORTS:
364365
* | @HID_QUIRK_NO_IGNORE:
@@ -384,6 +385,7 @@ struct hid_item {
384385
#define HID_QUIRK_HAVE_SPECIAL_DRIVER BIT(19)
385386
#define HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE BIT(20)
386387
#define HID_QUIRK_NOINVERT BIT(21)
388+
#define HID_QUIRK_IGNORE_SPECIAL_DRIVER BIT(22)
387389
#define HID_QUIRK_FULLSPEED_INTERVAL BIT(28)
388390
#define HID_QUIRK_NO_INIT_REPORTS BIT(29)
389391
#define HID_QUIRK_NO_IGNORE BIT(30)

0 commit comments

Comments
 (0)