[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2026011231-kitten-stainable-7206@gregkh>
Date: Mon, 12 Jan 2026 16:03:58 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Danilo Krummrich <dakr@...nel.org>
Cc: rafael@...nel.org, igor.korotin.linux@...il.com, ojeda@...nel.org,
boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
lossin@...nel.org, a.hindborg@...nel.org, aliceryhl@...gle.com,
tmgross@...ch.edu, david.m.ertman@...el.com, ira.weiny@...el.com,
leon@...nel.org, bhelgaas@...gle.com, kwilczynski@...nel.org,
wsa+renesas@...g-engineering.com, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-pci@...r.kernel.org,
linux-usb@...r.kernel.org, linux-i2c@...r.kernel.org
Subject: Re: [PATCH 6/6] rust: driver: drop device private data post unbind
On Mon, Jan 12, 2026 at 03:27:08PM +0100, Danilo Krummrich wrote:
> On Wed Jan 7, 2026 at 3:54 PM CET, Greg KH wrote:
> > I say name it with "rust_" and take out the #ifdef, that makes it
> > simpler/easier to understand.
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 2d9871503614..bea8da5f8a3a 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -548,10 +548,8 @@ static DEVICE_ATTR_RW(state_synced);
> static void device_unbind_cleanup(struct device *dev)
> {
> devres_release_all(dev);
> -#ifdef CONFIG_RUST
> - if (dev->driver->p_cb.post_unbind)
> - dev->driver->p_cb.post_unbind(dev);
> -#endif
> + if (dev->driver->p_cb.post_unbind_rust)
> + dev->driver->p_cb.post_unbind_rust(dev);
> arch_teardown_dma_ops(dev);
> kfree(dev->dma_range_map);
> dev->dma_range_map = NULL;
> diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
> index 51a9ebdd8a2d..bbc67ec513ed 100644
> --- a/include/linux/device/driver.h
> +++ b/include/linux/device/driver.h
> @@ -121,15 +121,13 @@ struct device_driver {
> void (*coredump) (struct device *dev);
>
> struct driver_private *p;
> -#ifdef CONFIG_RUST
> struct {
> /*
> * Called after remove() and after all devres entries have been
> - * processed.
> + * processed. This is a Rust only callback.
> */
> - void (*post_unbind)(struct device *dev);
> + void (*post_unbind_rust)(struct device *dev);
> } p_cb;
> -#endif
> };
>
>
> diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
> index 6e32376d4c7c..26095d7bd0d9 100644
> --- a/rust/kernel/driver.rs
> +++ b/rust/kernel/driver.rs
> @@ -207,7 +207,7 @@ fn callbacks_attach(drv: &Opaque<T::DriverType>) {
> let base = base.cast::<bindings::device_driver>();
>
> // SAFETY: It is safe to set the fields of `struct device_driver` on initialization.
> - unsafe { (*base).p_cb.post_unbind = Some(Self::post_unbind_callback) };
> + unsafe { (*base).p_cb.post_unbind_rust = Some(Self::post_unbind_callback) };
> }
>
> /// Creates a new instance of the registration object.
Looks good to me, thanks!
Powered by blists - more mailing lists