[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <96c45391-e6e3-4972-b8ec-b611be655624@kernel.org>
Date: Tue, 23 Sep 2025 17:06:30 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: 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 9/23/25 4:52 PM, Greg Kroah-Hartman wrote:
>> 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).
>
> Wait, usb_device_driver shouldn't be used here, that's only for
> "special" things like hubs and an odd Apple device.
I only mentioned it because if a struct usb_device is bound, then it is bound to
a struct usb_device_driver.
And because we're not doing this, I doubt that a *public* usb::Device
abstraction is required (at least for now).
The cases where we need a struct usb_device for operations on USB interface
(such as usb_fill_bulk_urb(), usb_submit_urb(), etc.) can be dealt with
internally in the abstraction itself, such that drivers only need to know about
the interface.
So, I wouldn't expose it just yet. If we see that further down the road we need
usb_interface drivers to mess with the usb_device directly for some reason, we
can still expose it.
>> 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).
>
> Interfaces are bound to usb_driver, and are a child device of a struct
> usb_device. There is no need to worry if a driver is bound to a struct
> usb_device at any time, it should be independent if a driver is bound to
> a struct interface. All that we should care about is the driver that is
> bound to a usb_interface as that is what the rust binding should be for
> here.
Right, that's why I said I doubt that it is semantically useful to derive a
&usb::Device<Bound> from a &usb::Interface<Bound> or a &usb::Device<Core> from a
&usb::Interface<Core>.
But besides that I also think it's also just wrong, so we should remove the
corresponding code.
Powered by blists - more mailing lists