[PATCH v3 1/4] HID: generic: Respect specialized drivers match callbacks
From: Vas Zayarskiy
Date: Mon Sep 14 2026 - 19:38:43 EST
A driver can reject an interface in its match callback even when its ID
table matches. hid-generic currently yields based on the ID table alone,
leaving such an interface without a driver.
Consult the callback after matching the ID table so hid-generic can keep
interfaces declined by specialized drivers. This allows the AMPINEL
hwmon driver to leave the separate keyboard interface to hid-generic.
The same callback check was proposed previously for Logitech devices:
Link: https://lkml.iu.edu/hypermail/linux/kernel/2212.0/06724.html
Assisted-by: LLM sparse
Signed-off-by: Vas Zayarskiy <contact@xxxxxxxxx>
---
drivers/hid/hid-generic.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-generic.c b/drivers/hid/hid-generic.c
index c2de91674..ebc38ae76 100644
--- a/drivers/hid/hid-generic.c
+++ b/drivers/hid/hid-generic.c
@@ -31,7 +31,13 @@ static int __check_hid_generic(struct device_driver *drv, void *data)
if (hdrv == &hid_generic)
return 0;
- return hid_match_device(hdev, hdrv) != NULL;
+ if (!hid_match_device(hdev, hdrv))
+ return 0;
+
+ if (hdrv->match)
+ return hdrv->match(hdev, false);
+
+ return 1;
}
static bool hid_generic_match(struct hid_device *hdev,