Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: Allow bus wildcard matching

Most HID drivers do not need to know what bus driver is in use.
A generic group driver can drive any hid device, and the device
list should not need to be duplicated for each new bus.

This patch adds wildcard matching to the HID bus, simplifying device
list handling for group drivers.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Henrik Rydberg and committed by
Jiri Kosina
7431fb76 734c6609

+4 -2
+1 -1
drivers/hid/hid-core.c
··· 1273 1273 static bool hid_match_one_id(struct hid_device *hdev, 1274 1274 const struct hid_device_id *id) 1275 1275 { 1276 - return id->bus == hdev->bus && 1276 + return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) && 1277 1277 (id->group == HID_GROUP_ANY || id->group == hdev->group) && 1278 1278 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 1279 1279 (id->product == HID_ANY_ID || id->product == hdev->product);
+1
include/linux/mod_devicetable.h
··· 132 132 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 133 133 134 134 #define HID_ANY_ID (~0) 135 + #define HID_BUS_ANY 0xffff 135 136 #define HID_GROUP_ANY 0x0000 136 137 137 138 struct hid_device_id {
+2 -1
scripts/mod/file2alias.c
··· 340 340 id->vendor = TO_NATIVE(id->vendor); 341 341 id->product = TO_NATIVE(id->product); 342 342 343 - sprintf(alias, "hid:b%04X", id->bus); 343 + sprintf(alias, "hid:"); 344 + ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); 344 345 ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); 345 346 ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); 346 347 ADD(alias, "p", id->product != HID_ANY_ID, id->product);