Commit 7431fb76 authored by Henrik Rydberg's avatar Henrik Rydberg Committed by Jiri Kosina

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: default avatarHenrik Rydberg <rydberg@euromail.se>
Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 734c6609
...@@ -1273,7 +1273,7 @@ EXPORT_SYMBOL_GPL(hid_input_report); ...@@ -1273,7 +1273,7 @@ EXPORT_SYMBOL_GPL(hid_input_report);
static bool hid_match_one_id(struct hid_device *hdev, static bool hid_match_one_id(struct hid_device *hdev,
const struct hid_device_id *id) 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->group == HID_GROUP_ANY || id->group == hdev->group) &&
(id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
(id->product == HID_ANY_ID || id->product == hdev->product); (id->product == HID_ANY_ID || id->product == hdev->product);
......
...@@ -132,6 +132,7 @@ struct usb_device_id { ...@@ -132,6 +132,7 @@ struct usb_device_id {
#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
#define HID_ANY_ID (~0) #define HID_ANY_ID (~0)
#define HID_BUS_ANY 0xffff
#define HID_GROUP_ANY 0x0000 #define HID_GROUP_ANY 0x0000
struct hid_device_id { struct hid_device_id {
......
...@@ -340,7 +340,8 @@ static int do_hid_entry(const char *filename, ...@@ -340,7 +340,8 @@ static int do_hid_entry(const char *filename,
id->vendor = TO_NATIVE(id->vendor); id->vendor = TO_NATIVE(id->vendor);
id->product = TO_NATIVE(id->product); 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, "g", id->group != HID_GROUP_ANY, id->group);
ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor);
ADD(alias, "p", id->product != HID_ANY_ID, id->product); ADD(alias, "p", id->product != HID_ANY_ID, id->product);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment