[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6294DED6.70904@gmail.com>
Date: Mon, 30 May 2022 18:12:22 +0300
From: Eli Billauer <eli.billauer@...il.com>
To: Zheyu Ma <zheyuma97@...il.com>
CC: arnd@...db.de, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] char: xillybus: Check endpoint type at probe time
On 29/05/22 09:58, Zheyu Ma wrote:
> static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev)
> {
> + int ret;
> + struct usb_endpoint_descriptor *in, *out;
> +
> + ret = usb_find_common_endpoints(xdev->intf->cur_altsetting,&in,&out, NULL, NULL);
> + if (ret)
> + return ret;
> +
> + if (in->bEndpointAddress != (IN_EP_NUM | USB_DIR_IN) ||
> + out->bEndpointAddress != (MSG_EP_NUM | USB_DIR_OUT))
> + return -EINVAL;
> +
>
As far as I understand, this finds the first BULK endpoints in both
directions, and verifies that their addresses are MSG_EP_NUM and
IN_EP_NUM. Because both of these happen to equal 1, I suppose this
indeed checks the right thing. But am I right that this won't work if
either MSG_EP_NUM or IN_EP_NUM have a value that isn't 1? Not that I
think that will ever happen, but still.
> +static int xillyusb_check_endpoint(struct xillyusb_dev *xdev, u8 addr)
> +{
> + int i;
> + struct usb_host_interface *if_desc = xdev->intf->altsetting;
> +
> + for (i = 0; i< if_desc->desc.bNumEndpoints; i++) {
> + struct usb_endpoint_descriptor *ep =&if_desc->endpoint[i].desc;
> +
> + if (ep->bEndpointAddress == addr&& usb_endpoint_is_bulk_out(ep))
> + return 0;
> + }
> +
> + return -EINVAL;
> +}
> +
>
>
Given that you've added this function, why isn't it used in
xillyusb_setup_base_eps()?
Thanks,
Eli
Powered by blists - more mailing lists