]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
usb: gadget: net2280: Use USB API functions rather than constants
authorChen Ni <nichen@iscas.ac.cn>
Wed, 18 Jun 2025 04:02:04 +0000 (12:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jun 2025 10:24:06 +0000 (12:24 +0200)
Use the function usb_endpoint_num() and usb_endpoint_type()
rather than constants.

The Coccinelle semantic patch is as follows:

@@ struct usb_endpoint_descriptor *epd; @@

- (epd->bEndpointAddress & \(USB_ENDPOINT_NUMBER_MASK\|0x0f\))
+ usb_endpoint_num(epd)

@@ struct usb_endpoint_descriptor *epd; @@

- (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\))
+ usb_endpoint_type(epd)

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Link: https://lore.kernel.org/r/20250618040204.363383-1-nichen@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/net2280.c

index b2903e4bbf54d0308f99599aa529080b9cad3aca..8ea1adc7461d96e4c756367fce29428e2da22cd3 100644 (file)
@@ -203,13 +203,13 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
        }
 
        /* erratum 0119 workaround ties up an endpoint number */
-       if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE) {
+       if (usb_endpoint_num(desc) == EP_DONTUSE) {
                ret = -EDOM;
                goto print_err;
        }
 
        if (dev->quirks & PLX_PCIE) {
-               if ((desc->bEndpointAddress & 0x0f) >= 0x0c) {
+               if (usb_endpoint_num(desc) >= 0x0c) {
                        ret = -EDOM;
                        goto print_err;
                }
@@ -255,7 +255,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
                else
                        tmp &= ~USB3380_EP_CFG_MASK_OUT;
        }
-       type = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
+       type = usb_endpoint_type(desc);
        if (type == USB_ENDPOINT_XFER_INT) {
                /* erratum 0105 workaround prevents hs NYET */
                if (dev->chiprev == 0100 &&
@@ -1334,7 +1334,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
                retval = -ESHUTDOWN;
                goto print_err;
        }
-       if (ep->desc /* not ep0 */ && (ep->desc->bmAttributes & 0x03)
+       if (ep->desc /* not ep0 */ && usb_endpoint_type(ep->desc)
                                                == USB_ENDPOINT_XFER_ISOC) {
                retval = -EINVAL;
                goto print_err;