From: "Danilo Krummrich" <dakr@kernel.org>
To: "Greg KH" <gregkh@linuxfoundation.org>
Cc: <rafael@kernel.org>, <igor.korotin.linux@gmail.com>,
<ojeda@kernel.org>, <boqun.feng@gmail.com>, <gary@garyguo.net>,
<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
<a.hindborg@kernel.org>, <aliceryhl@google.com>,
<tmgross@umich.edu>, <david.m.ertman@intel.com>,
<ira.weiny@intel.com>, <leon@kernel.org>, <bhelgaas@google.com>,
<kwilczynski@kernel.org>, <wsa+renesas@sang-engineering.com>,
<linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
<linux-pci@vger.kernel.org>, <linux-usb@vger.kernel.org>,
<linux-i2c@vger.kernel.org>
Subject: Re: [PATCH 6/6] rust: driver: drop device private data post unbind
Date: Mon, 12 Jan 2026 15:27:08 +0100 [thread overview]
Message-ID: <DFMOIU3FC48L.17P3TCF92CEZZ@kernel.org> (raw)
In-Reply-To: <2026010701-rearview-retriever-3268@gregkh>
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.
next prev parent reply other threads:[~2026-01-12 14:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 10:34 [PATCH 0/6] Address race condition with Device::drvdata() Danilo Krummrich
2026-01-07 10:35 ` [PATCH 1/6] rust: i2c: do not drop device private data on shutdown() Danilo Krummrich
2026-01-07 10:35 ` [PATCH 2/6] rust: auxiliary: add Driver::unbind() callback Danilo Krummrich
2026-01-07 10:35 ` [PATCH 3/6] rust: driver: introduce a common Driver trait Danilo Krummrich
2026-01-14 19:40 ` Igor Korotin
2026-01-07 10:35 ` [PATCH 4/6] rust: driver: add DEVICE_DRIVER_OFFSET to the " Danilo Krummrich
2026-01-07 10:35 ` [PATCH 5/6] rust: driver: add DriverData type to the generic " Danilo Krummrich
2026-01-07 10:35 ` [PATCH 6/6] rust: driver: drop device private data post unbind Danilo Krummrich
2026-01-07 12:22 ` Greg KH
2026-01-07 12:50 ` Danilo Krummrich
2026-01-07 14:54 ` Greg KH
2026-01-12 14:27 ` Danilo Krummrich [this message]
2026-01-12 15:03 ` Greg KH
2026-01-07 15:51 ` [PATCH 0/6] Address race condition with Device::drvdata() Alice Ryhl
2026-01-07 16:40 ` Danilo Krummrich
2026-01-12 15:34 ` Alice Ryhl
2026-01-12 15:47 ` Danilo Krummrich
2026-01-14 19:50 ` Igor Korotin
2026-01-16 0:23 ` Danilo Krummrich
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=DFMOIU3FC48L.17P3TCF92CEZZ@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=david.m.ertman@intel.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=igor.korotin.linux@gmail.com \
--cc=ira.weiny@intel.com \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wsa+renesas@sang-engineering.com \
/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