[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <27AB9C59-BAE6-4F1F-8638-DF9244D0A616@collabora.com>
Date: Tue, 23 Sep 2025 15:31:26 +0200
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: 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>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
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
Hi Danilo,
>> +/// A USB device.
>> +///
>> +/// This structure represents the Rust abstraction for a C [`struct usb_device`].
>> +/// The implementation abstracts the usage of a C [`struct usb_device`] passed in
>> +/// from the C side.
>> +///
>> +/// # Invariants
>> +///
>> +/// A [`Device`] instance represents a valid [`struct usb_device`] created by the C portion of the
>> +/// kernel.
>> +///
>> +/// [`struct usb_device`]: https://www.kernel.org/doc/html/latest/driver-api/usb/usb.html#c.usb_device
>> +#[repr(transparent)]
>> +pub struct Device<Ctx: device::DeviceContext = device::Normal>(
>> + Opaque<bindings::usb_device>,
>> + PhantomData<Ctx>,
>> +);
>
> What do you use the struct usb_device abstraction for? I only see the sample
> driver probing a USB interface instead.
What I was brainstorming with Greg is to submit this initial support, and then
follow up with all the other abstractions needed to implement a Rust version of
usb-skeleton.c. IIUC, the plan is to submit any fixes as follow-ups, as we're
close to the merge window.
struct usb_device would be used for the skeleton driver, so we should keep it if
we're following the plan above, IMHO.
— Daniel
Powered by blists - more mailing lists