From: Eli Billauer <eli.billauer@gmail.com>
To: Zheyu Ma <zheyuma97@gmail.com>
Cc: arnd@arndb.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] char: xillybus: Check endpoint type at probe time
Date: Mon, 30 May 2022 18:12:22 +0300 [thread overview]
Message-ID: <6294DED6.70904@gmail.com> (raw)
In-Reply-To: <20220529065839.3817434-1-zheyuma97@gmail.com>
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
next prev parent reply other threads:[~2022-05-30 15:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-29 6:58 [PATCH v3] char: xillybus: Check endpoint type at probe time Zheyu Ma
2022-05-30 15:12 ` Eli Billauer [this message]
2022-05-31 3:50 ` Zheyu Ma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6294DED6.70904@gmail.com \
--to=eli.billauer@gmail.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zheyuma97@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).