From 2bca6874888dcf8f3fce5165f3db1e3e2ff03cf5 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 23 Apr 2012 12:07:04 +0200 Subject: [PATCH] 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. Change-Id: I11f26a31f3e6edb7d345c6def7e9dbfe6df6bad9 Signed-off-by: Henrik Rydberg Acked-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Kevin F. Haggerty --- drivers/hid/hid-core.c | 2 +- include/linux/mod_devicetable.h | 1 + scripts/mod/file2alias.c | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 2a5a2e897e4..626aa5d7be2 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1360,7 +1360,7 @@ EXPORT_SYMBOL_GPL(hid_input_report); static bool hid_match_one_id(struct hid_device *hdev, const struct hid_device_id *id) { - return id->bus == hdev->bus && + return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) && (id->group == HID_GROUP_ANY || id->group == hdev->group) && (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && (id->product == HID_ANY_ID || id->product == hdev->product); diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 102d73e4860..2bbb07cff7e 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -139,6 +139,7 @@ struct usb_device_id { #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400 #define HID_ANY_ID (~0) +#define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 struct hid_device_id { diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 740ca6345f3..73d862e13ff 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -343,7 +343,8 @@ static int do_hid_entry(const char *filename, id->vendor = TO_NATIVE(id->vendor); id->product = TO_NATIVE(id->product); - sprintf(alias, "hid:b%04X", id->bus); + sprintf(alias, "hid:"); + ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); ADD(alias, "p", id->product != HID_ANY_ID, id->product);