On 9/14/26 16:37, Vas Zayarskiy wrote:
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
That was from 2022 and seems to have been abandoned, making me wonder
if it is still broken for Logitech devices or if another solution
was found.
Guenter
quoted hunk ↗ jump to hunk
Assisted-by: LLM sparse
Signed-off-by: Vas Zayarskiy <redacted>
---
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,