From bf30f1256b88ef55d7a6611b775d02e03c05c314 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 12 Sep 2024 19:37:20 +0100 Subject: [PATCH] HID: usbhid: Insert USB bus/device ID into HID name libinput/wlroots/Wayfire/labwc match input device by the device name only. If you add 2 identical USB connected touch devices, you can't select between them. Add the usb bus&device name to the start of the name so that the names end up being unique, Signed-off-by: Dave Stevenson --- drivers/hid/usbhid/hid-core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index fb588ac24acc58..f129e61f8ece89 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1388,8 +1388,11 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * else if (intf->cur_altsetting->desc.bInterfaceProtocol == 0) hid->type = HID_TYPE_USBNONE; - if (dev->manufacturer) - strscpy(hid->name, dev->manufacturer, sizeof(hid->name)); + snprintf(hid->name, sizeof(hid->name), "usb-%s ", dev_name(&dev->dev)); + + if (dev->manufacturer) { + strlcat(hid->name, dev->manufacturer, sizeof(hid->name)); + } if (dev->product) { if (dev->manufacturer) @@ -1397,8 +1400,9 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * strlcat(hid->name, dev->product, sizeof(hid->name)); } - if (!strlen(hid->name)) - snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", + if (strlen(hid->name) == strlen(dev_name(&dev->dev))) + snprintf(hid->name, sizeof(hid->name), "usb-%s HID %04x:%04x", + dev_name(&dev->dev), le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct));