[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DAA7CJOUJPNL.F7UH9KD8JANF@kernel.org>
Date: Sat, 31 May 2025 10:27:44 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Danilo Krummrich" <dakr@...nel.org>, <gregkh@...uxfoundation.org>,
<rafael@...nel.org>, <ojeda@...nel.org>, <alex.gaynor@...il.com>,
<boqun.feng@...il.com>, <gary@...yguo.net>, <bjorn3_gh@...tonmail.com>,
<benno.lossin@...ton.me>, <a.hindborg@...nel.org>, <aliceryhl@...gle.com>,
<tmgross@...ch.edu>, <chrisi.schrefl@...il.com>
Cc: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 6/7] rust: miscdevice: expose the parent device as
&Device<Bound>
On Fri May 30, 2025 at 4:24 PM CEST, Danilo Krummrich wrote:
> @@ -227,11 +229,21 @@ fn drop(self: Pin<&mut Self>) {
> }
> }
>
> +/// The arguments passed to the file operation callbacks of a [`MiscDeviceRegistration`].
> +pub struct MiscArgs<'a, T: MiscDevice> {
> + /// The [`Device`] representation of the `struct miscdevice`.
> + pub device: &'a Device,
> + /// The parent [`Device`] of [`Self::device`].
> + pub parent: Option<&'a Device<Bound>>,
> + /// The `RegistrationData` passed to [`MiscDeviceRegistration::register`].
> + pub data: &'a T::RegistrationData,
Here I would also just use `T`, remove the `MiscDevice` bound and then
use `MiscArgs<'_, Self::RegistrationData>` below.
> +}
> +
> /// Trait implemented by the private data of an open misc device.
> #[vtable]
> pub trait MiscDevice: Sized {
> /// What kind of pointer should `Self` be wrapped in.
> - type Ptr: ForeignOwnable + Send + Sync;
> + type Ptr: Send + Sync;
There is no info about this change in the commit message. Why are we
changing this? This seems a bit orthogonal to the other change, maybe do
it in a separate patch?
Also `Ptr` doesn't make much sense for the name, since now that the
`ForeignOwnable` bound is gone, I could set this to `Self` and then have
access to `&Self` in the callbacks.
Would that also make sense to use as a general change? So don't store
`Self::Ptr`, but `Self` directly?
---
Cheers,
Benno
Powered by blists - more mailing lists