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 849 } 850 850 } 851 851 852 - if (!usbhid->urbin) { 853 - err_hid("couldn't find an input interrupt endpoint"); 854 - ret = -ENODEV; 855 - goto fail; 856 - } 857 - 858 852 init_waitqueue_head(&usbhid->wait); 859 853 INIT_WORK(&usbhid->reset_work, hid_reset); 860 854 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); ··· 942 948 943 949 static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) 944 950 { 951 + struct usb_host_interface *interface = intf->cur_altsetting; 945 952 struct usb_device *dev = interface_to_usbdev(intf); 946 953 struct usbhid_device *usbhid; 947 954 struct hid_device *hid; 955 + unsigned int n, has_in = 0; 948 956 size_t len; 949 957 int ret; 950 958 951 959 dbg_hid("HID probe called for ifnum %d\n", 952 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 + } 953 970 954 971 hid = hid_allocate_device(); 955 972 if (IS_ERR(hid))