From: Alan Stern <stern@rowland.harvard.edu>
To: Khalid Masum <khalid.masum.92@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kishon Vijay Abraham I <kishon@ti.com>,
Arnd Bergmann <arnd@arndb.de>,
Matthias Kaehlcke <mka@chromium.org>,
Alexey Sheplyakov <asheplyakov@basealt.ru>,
Weitao Wang <WeitaoWang-oc@zhaoxin.com>,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH] usb: host: Use helper function to get endpoint
Date: Wed, 24 Aug 2022 10:40:49 -0400 [thread overview]
Message-ID: <YwY4cVdB3tVVMIqJ@rowland.harvard.edu> (raw)
In-Reply-To: <20220824130702.10912-1-khalid.masum.92@gmail.com>
On Wed, Aug 24, 2022 at 07:07:02PM +0600, Khalid Masum wrote:
> Current implementation to convert urb pipe number to struct
> usb_host_endpoint in rquest_single_step_set_feature_urb is a little
> messy.
>
> Use usb_pipe_endpoint helper function to get the endpoint instead.
>
> Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
> ---
> drivers/usb/core/hcd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 94b305bbd621..107e29d5d3ae 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2165,8 +2165,7 @@ static struct urb *request_single_step_set_feature_urb(
> return NULL;
>
> urb->pipe = usb_rcvctrlpipe(udev, 0);
> - ep = (usb_pipein(urb->pipe) ? udev->ep_in : udev->ep_out)
> - [usb_pipeendpoint(urb->pipe)];
> + ep = usb_pipe_endpoint(udev, urb->pipe);
> if (!ep) {
> usb_free_urb(urb);
> return NULL;
Even this is awkward. It's silly to look up the endpoint in a table
when you already know that it is endpoint 0. Just do:
ep = &udev->ep0;
with no need to check for NULL.
Alan Stern
next prev parent reply other threads:[~2022-08-24 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 13:07 Khalid Masum
2022-08-24 14:40 ` Alan Stern [this message]
2022-08-24 16:55 ` Khalid Masum
2022-08-24 17:57 ` Khalid Masum
2022-08-24 19:24 ` Alan Stern
2022-08-24 20:36 ` Khalid Masum
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=YwY4cVdB3tVVMIqJ@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=WeitaoWang-oc@zhaoxin.com \
--cc=arnd@arndb.de \
--cc=asheplyakov@basealt.ru \
--cc=gregkh@linuxfoundation.org \
--cc=khalid.masum.92@gmail.com \
--cc=kishon@ti.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mka@chromium.org \
/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
all inboxes | Powered by JetHome®