]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: gspca: refactor endpoint lookup
authorJohan Hovold <johan@kernel.org>
Mon, 30 Mar 2026 10:11:39 +0000 (12:11 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 5 May 2026 14:57:02 +0000 (16:57 +0200)
Use the common USB helper for looking up interrupt-in endpoints instead
of open coding.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/usb/gspca/gspca.c

index f3d3f441c8510f391008bf2b54c1ee344ee85653..594d73e50b9fa4ce5c0771307c813c1fcefc14b3 100644 (file)
@@ -208,22 +208,17 @@ error:
 static void gspca_input_create_urb(struct gspca_dev *gspca_dev)
 {
        struct usb_interface *intf;
-       struct usb_host_interface *intf_desc;
        struct usb_endpoint_descriptor *ep;
-       int i;
+       int ret;
 
        if (gspca_dev->sd_desc->int_pkt_scan)  {
                intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface);
-               intf_desc = intf->cur_altsetting;
-               for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) {
-                       ep = &intf_desc->endpoint[i].desc;
-                       if (usb_endpoint_dir_in(ep) &&
-                           usb_endpoint_xfer_int(ep)) {
 
-                               alloc_and_submit_int_urb(gspca_dev, ep);
-                               break;
-                       }
-               }
+               ret = usb_find_int_in_endpoint(intf->cur_altsetting, &ep);
+               if (ret)
+                       return;
+
+               alloc_and_submit_int_urb(gspca_dev, ep);
        }
 }