[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260107103511.570525-3-dakr@kernel.org>
Date: Wed, 7 Jan 2026 11:35:01 +0100
From: Danilo Krummrich <dakr@...nel.org>
To: gregkh@...uxfoundation.org,
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
Cc: 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,
Danilo Krummrich <dakr@...nel.org>
Subject: [PATCH 2/6] rust: auxiliary: add Driver::unbind() callback
Add missing unbind() callback to auxiliary::Driver, since it will be
needed by drivers eventually (e.g. the Nova DRM driver).
Signed-off-by: Danilo Krummrich <dakr@...nel.org>
---
Strictly speaking, this is not a dependency, but without this patch the main
fix of this series leaves the remove() callback of the auxiliary bus
abstraction with either dead code or quite some code removed; code that we
would otherwise add back immediately afterwards.
---
rust/kernel/auxiliary.rs | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
index 56f3c180e8f6..6931f8a4267f 100644
--- a/rust/kernel/auxiliary.rs
+++ b/rust/kernel/auxiliary.rs
@@ -87,7 +87,9 @@ extern "C" fn remove_callback(adev: *mut bindings::auxiliary_device) {
// SAFETY: `remove_callback` is only ever called after a successful call to
// `probe_callback`, hence it's guaranteed that `Device::set_drvdata()` has been called
// and stored a `Pin<KBox<T>>`.
- drop(unsafe { adev.as_ref().drvdata_obtain::<T>() });
+ let data = unsafe { adev.as_ref().drvdata_obtain::<T>() };
+
+ T::unbind(adev, data.as_ref());
}
}
@@ -187,6 +189,20 @@ pub trait Driver {
///
/// Called when an auxiliary device is matches a corresponding driver.
fn probe(dev: &Device<device::Core>, id_info: &Self::IdInfo) -> impl PinInit<Self, Error>;
+
+ /// Auxiliary driver unbind.
+ ///
+ /// Called when a [`Device`] is unbound from its bound [`Driver`]. Implementing this callback
+ /// is optional.
+ ///
+ /// This callback serves as a place for drivers to perform teardown operations that require a
+ /// `&Device<Core>` or `&Device<Bound>` reference. For instance, drivers may try to perform I/O
+ /// operations to gracefully tear down the device.
+ ///
+ /// Otherwise, release operations for driver resources should be performed in `Self::drop`.
+ fn unbind(dev: &Device<device::Core>, this: Pin<&Self>) {
+ let _ = (dev, this);
+ }
}
/// The auxiliary device representation.
--
2.52.0
Powered by blists - more mailing lists