On Thu, Apr 19, 2012 at 12:00:53AM +0200, Henrik Rydberg wrote: > HID devices are only partially presented to userland. Hotplugged > devices emit events containing a modalias based on the basic bus, > vendor and product entities. However, in practise a hid device can > depend on details such as a single usb interface or a particular item > in a report descriptor. > > This patch adds a device group to the hid device id, and broadcasts it > using uevent and the device modalias. The module alias generation is > modified to match. As a consequence, a device with a non-zero group > will be processed by the corresponding group driver instead of by the > generic hid driver. > > Signed-off-by: Henrik Rydberg <rydberg@xxxxxxxxxxx> > --- Addition for v2: store_new_id() needs to be modified as well, in order for the added devices to match the right device group. Something like the below should suffice. Henrik --- diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 4845567..3c9bf3e 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -580,6 +576,17 @@ const struct hid_device_id *hid_match_id(struct hid_device *hdev, return NULL; } +static int hid_get_driver_group(const struct hid_driver *hdrv) +{ + const struct hid_device_id *id; + int group = 0; + + for (id = hdrv->id_table; id->bus; id++) + group = id->group; + + return group; +} + static const struct hid_device_id hid_hiddev_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, @@ -977,6 +984,7 @@ static ssize_t store_new_id(struct device_driver *drv, const char *buf, return -ENOMEM; dynid->id.bus = bus; + dynid->id.group = hid_get_driver_group(hdrv); dynid->id.vendor = vendor; dynid->id.product = product; dynid->id.driver_data = driver_data; -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html