Re: [PATCH] usb: gadget: dummy_hcd: Use USB API functions rather than constants

From: Alan Stern
Date: Wed Jun 18 2025 - 10:14:50 EST


On Wed, Jun 18, 2025 at 02:57:50PM +0800, Chen Ni wrote:
> 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)

You could make a similar change for usb_endpoint_dir_in() or
usb_endpoint_dir_out().

Alan Stern

>
> Signed-off-by: Chen Ni <nichen@xxxxxxxxxxx>
> ---
> drivers/usb/gadget/udc/dummy_hcd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
> index 27c9699365ab..21dbfb0b3bac 100644
> --- a/drivers/usb/gadget/udc/dummy_hcd.c
> +++ b/drivers/usb/gadget/udc/dummy_hcd.c
> @@ -623,7 +623,7 @@ static int dummy_enable(struct usb_ep *_ep,
>
> dev_dbg(udc_dev(dum), "enabled %s (ep%d%s-%s) maxpacket %d stream %s\n",
> _ep->name,
> - desc->bEndpointAddress & 0x0f,
> + usb_endpoint_num(desc),
> (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out",
> usb_ep_type_string(usb_endpoint_type(desc)),
> max, str_enabled_disabled(ep->stream_en));
> --
> 2.25.1
>