From: "Danilo Krummrich" <dakr@kernel.org>
To: "Colin Braun" <colinbrauncl@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Mathias Nyman" <mathias.nyman@intel.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-usb@vger.kernel.org, linux-media@vger.kernel.org,
"Colin Braun" <colin.braun.cl@gmail.com>,
oneukum@suse.com
Subject: Re: [RFC PATCH 2/4] rust: usb: add usb host interface and endpoint abstractions
Date: Mon, 13 Jul 2026 15:22:33 +0200 [thread overview]
Message-ID: <DJXH4JLX4CES.11S3IZ1V2FTHF@kernel.org> (raw)
In-Reply-To: <20260712-urb-abstraction-v1-v1-2-9fa011634ead@gmail.com>
(Cc: Oliver)
On Sun Jul 12, 2026 at 11:07 PM CEST, Colin Braun wrote:
> @@ -382,8 +556,8 @@ fn as_ref(&self) -> &device::Device<Ctx> {
> }
> }
>
> -impl<Ctx: device::DeviceContext> AsRef<Device> for Interface<Ctx> {
> - fn as_ref(&self) -> &Device {
> +impl<Ctx: device::DeviceContext> AsRef<Device<Ctx>> for Interface<Ctx> {
> + fn as_ref(&self) -> &Device<Ctx> {
> // SAFETY: `self.as_raw()` is valid by the type invariants.
> let usb_dev = unsafe { bindings::interface_to_usbdev(self.as_raw()) };
Please see commit f12140f21acb ("rust: usb: don't retain device context for the
interface parent").
We can't derive the device context of a USB device from a USB interface. Please
also see the device context documentation in [1].
USB device drivers are separate from USB interface drivers, we can't assume that
a USB device is bound to a USB device driver just because a USB interface (of
that same device) is bound to an USB interface driver.
The same is true from the Core context, which means the device is in a bus
device callback, where the device lock is held.
This is also the reason why I keep proposing to only expose simple forwarding
helpers on usb::Interface to implement URBs (see also [2] and [3]).
An URB requires either usb::Interface<Bound> or, for a USB device driver,
usb::Device<Bound>. But since we can't derive usb::Device<Bound> from
usb::Interface<Bound> a simple forwarding helper does the trick.
[1] https://rust.docs.kernel.org/kernel/device/trait.DeviceContext.html
[2] https://lore.kernel.org/lkml/DJRF98V7SMXT.14BS8WGBEESZ8@kernel.org/
[3] https://lore.kernel.org/lkml/24196da3-62e8-4707-8024-d989bcd5d3a8@rowland.harvard.edu/
next prev parent reply other threads:[~2026-07-13 13:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 21:07 [RFC PATCH 0/4] rust: usb: add usb request block abstractions and a user Colin Braun
2026-07-12 21:07 ` [RFC PATCH 1/4] rust: usb: add USB ch9 standard descriptors and constants Colin Braun
2026-07-12 21:07 ` [RFC PATCH 2/4] rust: usb: add usb host interface and endpoint abstractions Colin Braun
2026-07-13 13:22 ` Danilo Krummrich [this message]
2026-07-13 20:03 ` Colin Braun
2026-07-13 20:09 ` Danilo Krummrich
2026-07-14 9:26 ` Oliver Neukum
2026-07-12 21:08 ` [RFC PATCH 3/4] rust: usb: add urb abstraction with control and isochronous support Colin Braun
2026-07-12 21:08 ` [RFC PATCH 4/4] media: add gv-usb2 audio capture driver Colin Braun
2026-07-13 14:44 ` Danilo Krummrich
2026-07-13 21:08 ` Colin Braun
2026-07-13 13:22 ` [RFC PATCH 0/4] rust: usb: add usb request block abstractions and a user Danilo Krummrich
2026-07-13 20:10 ` Colin Braun
2026-07-13 13:53 ` Daniel Almeida
2026-07-13 20:32 ` Colin Braun
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=DJXH4JLX4CES.11S3IZ1V2FTHF@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=colin.braun.cl@gmail.com \
--cc=colinbrauncl@gmail.com \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mchehab@kernel.org \
--cc=ojeda@kernel.org \
--cc=oneukum@suse.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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