[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025022601-starlit-roamer-1687@gregkh>
Date: Wed, 26 Feb 2025 11:01:37 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Lyude Paul <lyude@...hat.com>
Cc: rust-for-linux@...r.kernel.org,
Maíra Canal <mairacanal@...eup.net>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] rust/faux: Add missing parent argument to
Registration::new()
On Tue, Feb 25, 2025 at 04:29:01PM -0500, Lyude Paul wrote:
> A little late in the review of the faux device interface, we added the
> ability to specify a parent device when creating new faux devices - but
> this never got ported over to the rust bindings. So, let's add the missing
> argument now so we don't have to convert other users later down the line.
>
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
> rust/kernel/faux.rs | 10 ++++++++--
> samples/rust/rust_driver_faux.rs | 2 +-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/rust/kernel/faux.rs b/rust/kernel/faux.rs
> index 41751403cd868..ae99ea3d114ef 100644
> --- a/rust/kernel/faux.rs
> +++ b/rust/kernel/faux.rs
> @@ -23,11 +23,17 @@
>
> impl Registration {
> /// Create and register a new faux device with the given name.
> - pub fn new(name: &CStr) -> Result<Self> {
> + pub fn new(name: &CStr, parent: Option<&device::Device>) -> Result<Self> {
> // SAFETY:
> // - `name` is copied by this function into its own storage
> // - `faux_ops` is safe to leave NULL according to the C API
> - let dev = unsafe { bindings::faux_device_create(name.as_char_ptr(), null_mut(), null()) };
> + let dev = unsafe {
> + bindings::faux_device_create(
> + name.as_char_ptr(),
> + parent.map_or(null_mut(), |p| p.as_raw()),
> + null(),
I guess you can add parent can be NULL to the SAFETY line?
Sorry, I thought I would just leave it this way without a parent pointer
until you actually had a user that needed it. And then we could add the
new parameter and fix up all callers. No need to add support for it yet
without that, changing apis is easy! :)
Do you have a real user for this any time soon?
thanks,
greg k-h
Powered by blists - more mailing lists