From: Alan Stern <stern@rowland.harvard.edu>
To: Roy Luo <royluo@google.com>
Cc: raychi@google.com, badhri@google.com,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Michael Grzeschik <m.grzeschik@pengutronix.de>,
Bastien Nocera <hadess@hadess.net>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Matthias Kaehlcke <mka@chromium.org>,
Flavio Suligoi <f.suligoi@asem.it>,
Douglas Anderson <dianders@chromium.org>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [RFC PATCH v1] usb: core: add sysfs entry for usb device state
Date: Thu, 25 May 2023 20:50:53 -0400 [thread overview]
Message-ID: <dfaa91d3-1169-4381-a2ef-83443ee3e4ce@rowland.harvard.edu> (raw)
In-Reply-To: <CA+zupgyErTsDEZYerfAeEyVF073x+aTW6HiWZRA+2Y=a7U4XVg@mail.gmail.com>
On Thu, May 25, 2023 at 01:31:17PM -0700, Roy Luo wrote:
> On Thu, May 25, 2023 at 12:10 PM Alan Stern <stern@rowland.harvard.edu> wrote:
> >
> > On Thu, May 25, 2023 at 11:46:23AM -0700, Roy Luo wrote:
> > > Alan, thanks for the quick response!
> > > Yes, port_dev->state is indeed the same as port_dev->child->state. However,
> > > I still add port_dev->state because port_dev->child won't be assigned until
> > > the corresponding usb_device is in ADDRESS state.
> > > I wish I can assign get port_dev->child assigned earlier, but I think
> > > the current design - assign port_dev->child and device_add() after ADDRESS
> > > state - also makes sense because there are many ways that the enumeration
> > > could fail in the early stage. By adding port_dev->state, I can link
> > > usb_device->state to usb_port as soon as the usb_device is created to get
> > > around the limitation of port_dev->child.
> > > I would be very happy to hear other ideas.
> >
> > Is there any real reason not to set port_dev->child as soon as the
> > usb_device structure is created? If enumeration fails, the pointer can
> > be cleared.
> >
> > Alan Stern
>
> Currently the usb core assumes the usb_device that port_dev->child points
> to is enumerated and port_dev->child->dev is registered when
> port_dev->child is present. Setting port_dev->child early would break this
> fundamental assumption, hence I'm a bit reluctant to go this way.
Well, you could remove that assumption by adding a "child_is_registered"
flag and explicitly checking it.
Alan Stern
next prev parent reply other threads:[~2023-05-26 0:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 17:38 Roy Luo
2023-05-25 18:02 ` Alan Stern
2023-05-25 18:46 ` Roy Luo
2023-05-25 19:10 ` Alan Stern
2023-05-25 20:31 ` Roy Luo
2023-05-26 0:50 ` Alan Stern [this message]
2023-05-26 7:42 ` Greg Kroah-Hartman
2023-05-26 18:34 ` Roy Luo
2023-05-26 18:47 ` Greg Kroah-Hartman
2023-05-26 19:25 ` Roy Luo
2023-05-26 19:13 ` Alan Stern
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=dfaa91d3-1169-4381-a2ef-83443ee3e4ce@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=badhri@google.com \
--cc=benjamin.tissoires@redhat.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dianders@chromium.org \
--cc=f.suligoi@asem.it \
--cc=gregkh@linuxfoundation.org \
--cc=hadess@hadess.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
--cc=mathias.nyman@linux.intel.com \
--cc=mka@chromium.org \
--cc=raychi@google.com \
--cc=royluo@google.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
all inboxes | Powered by JetHome®