HID: Allow bus wildcard matching
authorHenrik Rydberg <rydberg@euromail.se>
Mon, 23 Apr 2012 10:07:04 +0000 (12:07 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 1 May 2012 10:54:54 +0000 (12:54 +0200)
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>
drivers/hid/hid-core.c
include/linux/mod_devicetable.h
scripts/mod/file2alias.c

index f932cd533d49de507fcae1be7cc14989428691e1..20daee56d32571bd2eab5f6bc0b9158b52bed6e0 100644 (file)
@@ -1273,7 +1273,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);
index 55ed0b0dc610b969c8c4bb533b55f3c54116782b..5db93821f9c7d473d1d4fe87f9e3fc5d988044bb 100644 (file)
@@ -132,6 +132,7 @@ struct usb_device_id {
 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL       0x0200
 
 #define HID_ANY_ID                             (~0)
+#define HID_BUS_ANY                            0xffff
 #define HID_GROUP_ANY                          0x0000
 
 struct hid_device_id {
index fe967cee73716f605fb69bb4f2f39a3d0bee63b7..056de3104e75382c20ef2dd94c0f93ddf8fa0ab9 100644 (file)
@@ -340,7 +340,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);