[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YwZ6/qkEAk8867qh@rowland.harvard.edu>
Date: Wed, 24 Aug 2022 15:24:46 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Khalid Masum <khalid.masum.92@...il.com>
Cc: linux-usb@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Kishon Vijay Abraham I <kishon@...com>,
Arnd Bergmann <arnd@...db.de>,
Matthias Kaehlcke <mka@...omium.org>,
Alexey Sheplyakov <asheplyakov@...ealt.ru>,
Weitao Wang <WeitaoWang-oc@...oxin.com>,
linux-kernel-mentees
<linux-kernel-mentees@...ts.linuxfoundation.org>
Subject: Re: [PATCH] usb: host: Use helper function to get endpoint
On Wed, Aug 24, 2022 at 11:57:25PM +0600, Khalid Masum wrote:
> On Wed, Aug 24, 2022 at 8:40 PM Alan Stern <stern@...land.harvard.edu> wrote:
> >
> >
> > 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.
>
> After further checking, I realized that usb_device udev is created by
> ehset_single_step_set_feature and depends on usb_hcd and port. So I do
> not get why the endpoint is at udev->ep0. Can you help me with this?
udev is not a usb_device structure; it is a _pointer_ to a usb_device
structure. The pointer is created when ehset_single_step_set_feature()
calls usb_hub_find_child(), but the structure itself gets created long
before that, when the USB device is first detected and initialized.
You can see this happening where hub_port_connect() calls
usb_alloc_dev(). The ep0 field is filled in by hub_port_init() and the
routines it calls.
Alan Stern
Powered by blists - more mailing lists