]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: image: microtek: cleanup ep handling
authorOliver Neukum <oneukum@suse.com>
Thu, 5 Mar 2026 10:28:31 +0000 (11:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Mar 2026 14:14:10 +0000 (15:14 +0100)
We now have macros for endpoint numbers, types and directions.
Use them.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://patch.msgid.link/20260305102905.2392512-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/image/microtek.c

index 45dc209f5fe5e7d0ea992023a2139e09d95279f3..3d58166f9d6182a5cbf18897a794c448a96ec610 100644 (file)
@@ -688,28 +688,20 @@ static int mts_usb_probe(struct usb_interface *intf,
        }
 
        for( i = 0; i < altsetting->desc.bNumEndpoints; i++ ) {
-               if ((altsetting->endpoint[i].desc.bmAttributes &
-                    USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) {
-
-                       MTS_WARNING( "can only deal with bulk endpoints; endpoint %d is not bulk.\n",
-                            (int)altsetting->endpoint[i].desc.bEndpointAddress );
-               } else {
-                       if (altsetting->endpoint[i].desc.bEndpointAddress &
-                           USB_DIR_IN)
-                               *ep_in_current++
-                                       = altsetting->endpoint[i].desc.bEndpointAddress &
-                                       USB_ENDPOINT_NUMBER_MASK;
-                       else {
-                               if ( ep_out != -1 ) {
-                                       MTS_WARNING( "can only deal with one output endpoints. Bailing out." );
-                                       return -ENODEV;
-                               }
-
-                               ep_out = altsetting->endpoint[i].desc.bEndpointAddress &
-                                       USB_ENDPOINT_NUMBER_MASK;
+               if (usb_endpoint_is_bulk_in(&altsetting->endpoint[i].desc)) {
+                       *ep_in_current++ = usb_endpoint_num(&altsetting->endpoint[i].desc);
+               } else if (usb_endpoint_is_bulk_out(&altsetting->endpoint[i].desc)) {
+                       if (ep_out == -1) {
+                               ep_out = usb_endpoint_num(&altsetting->endpoint[i].desc);
+                       } else {
+                               MTS_WARNING( "can only deal with bulk endpoints; endpoint %d is not bulk.\n",
+                                               usb_endpoint_num(&altsetting->endpoint[i].desc));
+                               return -ENODEV;
                        }
+               } else {
+                       MTS_WARNING( "can only deal with bulk endpoints; endpoint %d is not bulk.\n",
+                                       (int)altsetting->endpoint[i].desc.bEndpointAddress );
                }
-
        }
 
        if (ep_in_current != &ep_in_set[2]) {