All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Gary Guo <gary@garyguo.net>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"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>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: miscdevice: add registration data to MiscDevice
Date: Sat, 8 Aug 2026 13:53:16 +0000	[thread overview]
Message-ID: <anc0zESlTrEoBv8I@google.com> (raw)
In-Reply-To: <DKITW7C1POAV.QX2CZS7JQ6BM@garyguo.net>

On Fri, Aug 07, 2026 at 04:48:53PM +0100, Gary Guo wrote:
> On Fri Aug 7, 2026 at 4:44 PM BST, Alice Ryhl wrote:
> > On Fri, Aug 7, 2026 at 4:43 PM Gary Guo <gary@garyguo.net> wrote:
> >>
> >> On Fri Aug 7, 2026 at 3:22 PM BST, Alice Ryhl wrote:
> >> >  impl<T: MiscDevice> MiscDeviceRegistration<T> {
> >> >      /// Register a misc device.
> >> > -    pub fn register(opts: MiscDeviceOptions) -> impl PinInit<Self, Error> {
> >> > +    pub fn register(
> >> > +        opts: MiscDeviceOptions,
> >> > +        data: impl PinInit<T::RegistrationData, Error>,
> >>
> >> We can just skip the `RegistrationData` and use `T`?
> >
> > `T` is the type of the data stored per-fd. We do not separate types
> > for those two concepts.
> 
> This is getting backwards though, and won't work when we need to introduce
> lifetimes.
> 
> Per-fd data needs to be able to reference whatever lifetime is available on
> per-reg data, so it should be assoc type of the per-reg data type. The way
> around you current have causes `T::RegistrationData` to be able to reference
> lifetimes on `T` which is not okay and would only work with `'static` data.

Unfortunately the fds can outlive the registration, so we can't have
such lifetimes to begin with.

I know that miscdevice isn't currently built to work with the new device
model. We should fix that, but it is out of scope for this patch. Until
then, I think the current solution in this patch is sufficient.

Alice

  reply	other threads:[~2026-08-08 13:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 14:22 [PATCH] rust: miscdevice: add registration data to MiscDevice Alice Ryhl
2026-08-07 14:43 ` Gary Guo
2026-08-07 15:44   ` Alice Ryhl
2026-08-07 15:48     ` Gary Guo
2026-08-08 13:53       ` Alice Ryhl [this message]
2026-08-09 11:50         ` Gary Guo

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=anc0zESlTrEoBv8I@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.