rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: "Christian Schrefl" <chrisi.schrefl@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Arnd Bergmann" <arnd@arndb.de>, "Lee Jones" <lee@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Gerald Wisböck" <gerald.wisboeck@feather.ink>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] rust: miscdevice: add additional data to MiscDeviceRegistration
Date: Wed, 21 May 2025 13:55:36 +0200	[thread overview]
Message-ID: <2025052107-awhile-drainer-38d0@gregkh> (raw)
In-Reply-To: <aCiSRZjOETsD8MhX@pollux>

On Sat, May 17, 2025 at 03:42:29PM +0200, Danilo Krummrich wrote:
> On Sat, May 17, 2025 at 01:33:49PM +0200, Christian Schrefl wrote:
> > +pub struct MiscDeviceRegistration<T: MiscDevice> {
> >      #[pin]
> >      inner: Opaque<bindings::miscdevice>,
> > +    #[pin]
> > +    data: UnsafePinned<T::RegistrationData>,
> >      _t: PhantomData<T>,
> >  }
> 
> I recommend not to store data within a Registration type itself.
> 
> I know that this is designed with the focus on using misc device directly from
> the module scope; and in this context it works great.
> 
> However, it becomes quite suboptimal when used from a driver scope. For
> instance, if the misc device is registered within a platform driver's probe()
> function.
> 
> I know this probably isn't supported yet. At least, I assume it isn't supported
> "officially", given that the abstraction does not provide an option to set a
> parent device. Yet I think we should consider it.

It's going to be a requirement to properly set the parent device, and
as you point out, this really should be in some sort of scope, not just
a module.

But, we have two types of users of a misc device, one like this is
written, for a module-scope, and one for the "normal" device scope.  The
device scope is going to be tricker as it can, and will, get
disconnected from the device separately from the misc device lifespan,
so when that logic is added, it's going to be tricky as you point out.

So I'll take this now, but in the future this is going to have to be
cleaned up and modified.

thanks,

greg k-h

  parent reply	other threads:[~2025-05-21 11:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-17 11:33 [PATCH v3 0/2] rust: miscdevice: add additional data to MiscDeviceRegistration Christian Schrefl
2025-05-17 11:33 ` [PATCH v3 1/2] " Christian Schrefl
2025-05-17 13:42   ` Danilo Krummrich
2025-05-19 18:16     ` Boqun Feng
2025-05-21 11:55     ` Greg Kroah-Hartman [this message]
2025-05-21 12:04       ` Greg Kroah-Hartman
2025-05-21 12:16         ` Christian Schrefl
2025-05-21 13:00           ` Greg Kroah-Hartman
2025-05-21 23:01           ` Alice Ryhl
2025-05-21 14:12       ` Danilo Krummrich
2025-05-21 14:41         ` Christian Schrefl
2025-05-17 11:33 ` [PATCH v3 2/2] rust: miscdevice: adjust the rust_misc_device sample to use RegistrationData Christian Schrefl
2025-05-19 18:06 ` [PATCH v3 0/2] rust: miscdevice: add additional data to MiscDeviceRegistration Alice Ryhl

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=2025052107-awhile-drainer-38d0@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=arnd@arndb.de \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=chrisi.schrefl@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=gerald.wisboeck@feather.ink \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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;
as well as URLs for NNTP newsgroup(s).