usb: core: config: Use USB API functions rather than constants
authorChen Ni <nichen@iscas.ac.cn>
Mon, 19 May 2025 06:13:17 +0000 (14:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 May 2025 11:13:18 +0000 (13:13 +0200)
Use the function usb_endpoint_num() 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)

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

index 13bd4ec4ea5f7a6fef615b6f50b1acb3bbe44ba4..fc0cfd94cbab22b642024924c9196455eb7602e3 100644 (file)
@@ -307,7 +307,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
                goto skip_to_next_endpoint_or_interface_descriptor;
        }
 
-       i = d->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+       i = usb_endpoint_num(d);
        if (i == 0) {
                dev_notice(ddev, "config %d interface %d altsetting %d has an "
                    "invalid descriptor for endpoint zero, skipping\n",