HID: don't grab devices with no input

Some devices have no input interrupt endpoint. These won't be handled
by usbhid, but currently they are not refused and reside on hid bus.

Perform this checking earlier so that we refuse to control such
a device early enough (and not pass it to the hid bus at all).

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by Jiri Slaby and committed by Jiri Kosina 131d3a7a 62a56582

+11 -6
+11 -6
drivers/hid/usbhid/hid-core.c
··· 849 } 850 } 851 852 - if (!usbhid->urbin) { 853 - err_hid("couldn't find an input interrupt endpoint"); 854 - ret = -ENODEV; 855 - goto fail; 856 - } 857 - 858 init_waitqueue_head(&usbhid->wait); 859 INIT_WORK(&usbhid->reset_work, hid_reset); 860 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); ··· 942 943 static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) 944 { 945 struct usb_device *dev = interface_to_usbdev(intf); 946 struct usbhid_device *usbhid; 947 struct hid_device *hid; 948 size_t len; 949 int ret; 950 951 dbg_hid("HID probe called for ifnum %d\n", 952 intf->altsetting->desc.bInterfaceNumber); 953 954 hid = hid_allocate_device(); 955 if (IS_ERR(hid))
··· 849 } 850 } 851 852 init_waitqueue_head(&usbhid->wait); 853 INIT_WORK(&usbhid->reset_work, hid_reset); 854 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); ··· 948 949 static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) 950 { 951 + struct usb_host_interface *interface = intf->cur_altsetting; 952 struct usb_device *dev = interface_to_usbdev(intf); 953 struct usbhid_device *usbhid; 954 struct hid_device *hid; 955 + unsigned int n, has_in = 0; 956 size_t len; 957 int ret; 958 959 dbg_hid("HID probe called for ifnum %d\n", 960 intf->altsetting->desc.bInterfaceNumber); 961 + 962 + for (n = 0; n < interface->desc.bNumEndpoints; n++) 963 + if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) 964 + has_in++; 965 + if (!has_in) { 966 + dev_err(&intf->dev, "couldn't find an input interrupt " 967 + "endpoint\n"); 968 + return -ENODEV; 969 + } 970 971 hid = hid_allocate_device(); 972 if (IS_ERR(hid))