[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0ff2a825-1115-426a-a6f9-df544cd0c5fc@rowland.harvard.edu>
Date: Tue, 23 Sep 2025 10:58:20 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Almeida <daniel.almeida@...labora.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-usb@...r.kernel.org
Subject: Re: [PATCH 1/2] rust: usb: add basic USB abstractions
On Tue, Sep 23, 2025 at 04:38:34PM +0200, Danilo Krummrich wrote:
> >> @Greg: Can we guarantee that a struct usb_device is always bound as long as one
> >> of its interfaces is still bound?
> >
> > Bound to what?
>
> Well, that's kinda my point. :)
>
> Having a &usb::Device<Bound> would mean that for the lifetime of the reference
> it is guaranteed that the usb::Device is bound to its USB device driver
> (struct usb_device_driver).
>
> The code above establishes that you can get a &usb::Device<Bound> from a
> &usb::Interface<Bound>, i.e. an interface that is bound to a USB driver
> (struct usb_driver).
>
> It also does establish the same with other device contexts, such as the Core
> context.
>
> Despite the question whether this is sematically useful, I doubt that this is
> a correct assumption to take.
The intention of the USB stack is that yes, a usb_device cannot have
children if it isn't bound to a usb_device_driver. However, we don't
try to guarantee that this is true; a particular driver might not
enforce this restriction.
There is a surprisingly large number of calls to
usb_register_device_driver() in the kernel (four in addition to the
standard one). I suppose a little auditing could ensure that these
drivers do deconfigure their devices when they unbind.
Alan Stern
Powered by blists - more mailing lists