Linux USB
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Mike Lothian" <mike@fireburn.co.uk>
Cc: linux-usb@vger.kernel.org, "Miguel Ojeda" <ojeda@kernel.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>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	rust-for-linux@vger.kernel.org, llvm@lists.linux.dev,
	gregkh@linuxfoundation.org, oneukum@suse.com,
	stern@rowland.harvard.edu
Subject: Re: [PATCH v3 0/5] rust: usb: host-side abstractions for a bulk-endpoint driver
Date: Wed, 26 Aug 2026 20:25:33 +0200	[thread overview]
Message-ID: <DKZ34IA4DZAF.16BWFH4JPGROV@kernel.org> (raw)
In-Reply-To: <20260826163101.4168-1-mike@fireburn.co.uk>

(Cc: Greg, Oliver, Alan)

On Wed Aug 26, 2026 at 6:30 PM CEST, Mike Lothian wrote:
>   v2 10/11, "keep usb::Device private and gate ...", is dropped entirely.
>     Oliver Neukum was right that it was conceptually wrong: USB does device
>     level operations, and hiding that behind an interface is a layering
>     violation. Device stays public

On an abstract level a USB interface is a device that is operated by some
driver, which is why from a driver core topology point of view, a struct
usb_interface *is* a struct device. And there is no layering violation in
shortening:

	intf.device().bulk_send();

to

	intf.bulk_send();

Now, I get that this might read a bit odd from a pure USB topology perspective,
but what this shortcut gives you is that it allows you to not create types with
incorrect type states intermediately.

If USB folks really want the API to have an indirection, so it matches the USB
topology reading a bit better, just create an abstract a new type, e.g.:

	struct IoDevice<'a> {
	    intf: &'a usb::Interface<Bound>,
	}

which only provides the corresponding I/O methods, but does not give you access
to a "real" usb::Device<Bound>. This way you can still write:

	intf.device().bulk_send();

if that's preferrable.

Interestingly, looking at your series, it already does something like this, but
it's called IoWindow and oddly reimplements the lifecycle constraints the Rust
driver core infrastructure already provides.

> Alan Stern's lifecycle point is what makes device access from an interface
> sound, and is worth restating because the whole shape depends on it: an
> unconfigured device has no interfaces, so an interface that exists implies a
> configured device

Well, Alan also said this:

"At first I thought that we ought to have such a guarantee.  But in fact we
don't, because the user can at any time write to a USB device's
bConfigurationValue sysfs attribute even if the device isn't bound to a driver.
This can create interfaces which may then be bound to drivers."

This was a reply to me asking:

"So, what you're saying is that, in the generic case, there is a guarantee that
if a usb_interface is bound to a usb_driver, then the usb_interface's parent
usb_device is also bound to a usb_device_driver."

      parent reply	other threads:[~2026-08-26 18:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 16:30 [PATCH v3 0/5] rust: usb: host-side abstractions for a bulk-endpoint driver Mike Lothian
2026-08-26 16:30 ` [PATCH v3 1/5] rust: usb: add revocable typed interface I/O Mike Lothian
2026-08-26 18:59   ` Danilo Krummrich
2026-08-26 16:30 ` [PATCH v3 2/5] rust: usb: add reusable URBs and persistent bulk queues Mike Lothian
2026-08-26 16:30 ` [PATCH v3 3/5] rust: usb: expose device descriptor fields and queue readiness Mike Lothian
2026-08-26 16:30 ` [PATCH v3 4/5] rust: usb: add a vendor-and-interface-info device id constructor Mike Lothian
2026-08-26 16:30 ` [PATCH v3 5/5] rust: usb: let a driver keep its interface usable while unbinding Mike Lothian
2026-08-26 18:25 ` Danilo Krummrich [this message]

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=DKZ34IA4DZAF.16BWFH4JPGROV@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=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=justinstitt@google.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=lossin@kernel.org \
    --cc=mike@fireburn.co.uk \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --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