Skip to contentSkip to conversation

HID: usbhid: refactor endpoint lookup

PATCH In review Johan Hovold 2 participants 2 messages Mar 30 – Apr 9

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: usbhid: refactor endpoint lookup

Use the common USB helper for looking up interrupt-in endpoints instead of open coding.

---
 drivers/hid/usbhid/hid-core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/hid/usbhid/hid-core.c +3 -5
index ddd5d77fb5a5..2447bc7cb7a1 100644
@@ -1363,19 +1363,17 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
 {
 	struct usb_host_interface *interface = intf->cur_altsetting;
 	struct usb_device *dev = interface_to_usbdev(intf);
+	struct usb_endpoint_descriptor *ep;
 	struct usbhid_device *usbhid;
 	struct hid_device *hid;
-	unsigned int n, has_in = 0;
 	size_t len;
 	int ret;
 
 	dbg_hid("HID probe called for ifnum %d\n",
 			intf->altsetting->desc.bInterfaceNumber);
 
-	for (n = 0; n < interface->desc.bNumEndpoints; n++)
-		if (usb_endpoint_is_int_in(&interface->endpoint[n].desc))
-			has_in++;
-	if (!has_in) {
+	ret = usb_find_int_in_endpoint(interface, &ep);
+	if (ret) {
 		hid_err(intf, "couldn't find an input interrupt endpoint\n");
 		return -ENODEV;
 	}
Signature · 1 line
2.52.0
maintainer
#1 lore raw
Quoted 2 lines · Johan Hovold

Use the common USB helper for looking up interrupt-in endpoints instead of open coding.

Good catch, thanks Johan. Now applied to hid.git#for-7.1/core-v2.

Signature · 2 lines
Jiri Kosina
SUSE Labs