diff options
Diffstat (limited to 'drivers/usb/input/hid-core.c')
-rw-r--r-- | drivers/usb/input/hid-core.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 41f92b924761..411a0645a7a3 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -1619,8 +1619,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1619 | struct hid_descriptor *hdesc; | 1619 | struct hid_descriptor *hdesc; |
1620 | struct hid_device *hid; | 1620 | struct hid_device *hid; |
1621 | unsigned quirks = 0, rsize = 0; | 1621 | unsigned quirks = 0, rsize = 0; |
1622 | char *buf, *rdesc; | 1622 | char *rdesc; |
1623 | int n, insize = 0; | 1623 | int n, len, insize = 0; |
1624 | 1624 | ||
1625 | for (n = 0; hid_blacklist[n].idVendor; n++) | 1625 | for (n = 0; hid_blacklist[n].idVendor; n++) |
1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && | 1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
@@ -1630,10 +1630,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1630 | if (quirks & HID_QUIRK_IGNORE) | 1630 | if (quirks & HID_QUIRK_IGNORE) |
1631 | return NULL; | 1631 | return NULL; |
1632 | 1632 | ||
1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || | 1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
1634 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { | 1634 | (!interface->desc.bNumEndpoints || |
1635 | dbg("class descriptor not present\n"); | 1635 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
1636 | return NULL; | 1636 | dbg("class descriptor not present\n"); |
1637 | return NULL; | ||
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | for (n = 0; n < hdesc->bNumDescriptors; n++) | 1640 | for (n = 0; n < hdesc->bNumDescriptors; n++) |
@@ -1749,32 +1750,34 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1749 | 1750 | ||
1750 | hid->name[0] = 0; | 1751 | hid->name[0] = 0; |
1751 | 1752 | ||
1752 | if (!(buf = kmalloc(64, GFP_KERNEL))) | 1753 | if (dev->manufacturer) |
1753 | goto fail; | 1754 | strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); |
1755 | |||
1756 | if (dev->product) { | ||
1757 | if (dev->manufacturer) | ||
1758 | strlcat(hid->name, " ", sizeof(hid->name)); | ||
1759 | strlcat(hid->name, dev->product, sizeof(hid->name)); | ||
1760 | } | ||
1761 | |||
1762 | if (!strlen(hid->name)) | ||
1763 | snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", | ||
1764 | le16_to_cpu(dev->descriptor.idVendor), | ||
1765 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1754 | 1766 | ||
1755 | if (dev->manufacturer) { | 1767 | usb_make_path(dev, hid->phys, sizeof(hid->phys)); |
1756 | strcat(hid->name, dev->manufacturer); | 1768 | strlcat(hid->phys, "/input", sizeof(hid->phys)); |
1757 | if (dev->product) | 1769 | len = strlen(hid->phys); |
1758 | snprintf(hid->name, 64, "%s %s", hid->name, dev->product); | 1770 | if (len < sizeof(hid->phys) - 1) |
1759 | } else if (dev->product) { | 1771 | snprintf(hid->phys + len, sizeof(hid->phys) - len, |
1760 | snprintf(hid->name, 128, "%s", dev->product); | 1772 | "%d", intf->altsetting[0].desc.bInterfaceNumber); |
1761 | } else | ||
1762 | snprintf(hid->name, 128, "%04x:%04x", | ||
1763 | le16_to_cpu(dev->descriptor.idVendor), | ||
1764 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1765 | |||
1766 | usb_make_path(dev, buf, 64); | ||
1767 | snprintf(hid->phys, 64, "%s/input%d", buf, | ||
1768 | intf->altsetting[0].desc.bInterfaceNumber); | ||
1769 | 1773 | ||
1770 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1774 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
1771 | hid->uniq[0] = 0; | 1775 | hid->uniq[0] = 0; |
1772 | 1776 | ||
1773 | kfree(buf); | ||
1774 | |||
1775 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1777 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
1776 | if (!hid->urbctrl) | 1778 | if (!hid->urbctrl) |
1777 | goto fail; | 1779 | goto fail; |
1780 | |||
1778 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, | 1781 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, |
1779 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1782 | hid->ctrlbuf, 1, hid_ctrl, hid); |
1780 | hid->urbctrl->setup_dma = hid->cr_dma; | 1783 | hid->urbctrl->setup_dma = hid->cr_dma; |