Skip to content

Commit 7431fb7

Browse files
rydbergJiri Kosina
authored andcommitted
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>
1 parent 734c660 commit 7431fb7

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎drivers/hid/hid-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ EXPORT_SYMBOL_GPL(hid_input_report);
12731273
static bool hid_match_one_id(struct hid_device *hdev,
12741274
const struct hid_device_id *id)
12751275
{
1276-
return id->bus == hdev->bus &&
1276+
return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) &&
12771277
(id->group == HID_GROUP_ANY || id->group == hdev->group) &&
12781278
(id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
12791279
(id->product == HID_ANY_ID || id->product == hdev->product);

‎include/linux/mod_devicetable.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct usb_device_id {
132132
#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
133133

134134
#define HID_ANY_ID (~0)
135+
#define HID_BUS_ANY 0xffff
135136
#define HID_GROUP_ANY 0x0000
136137

137138
struct hid_device_id {

‎scripts/mod/file2alias.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ static int do_hid_entry(const char *filename,
340340
id->vendor = TO_NATIVE(id->vendor);
341341
id->product = TO_NATIVE(id->product);
342342

343-
sprintf(alias, "hid:b%04X", id->bus);
343+
sprintf(alias, "hid:");
344+
ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus);
344345
ADD(alias, "g", id->group != HID_GROUP_ANY, id->group);
345346
ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor);
346347
ADD(alias, "p", id->product != HID_ANY_ID, id->product);

0 commit comments

Comments
 (0)