From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
johan@kernel.org, david.m.ertman@intel.com, iweiny@kernel.org,
leon@kernel.org, ojeda@kernel.org, boqun@kernel.org,
gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
daniel.almeida@collabora.com, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev, igor.korotin@linux.dev,
bhelgaas@google.com, kwilczynski@kernel.org,
markus.probst@posteo.de
Cc: driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-serial@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH 3/7] rust: auxiliary: remove the unbind() callback
Date: Thu, 12 Nov 2026 01:52:57 +0100 [thread overview]
Message-ID: <20261112005455.1224352-4-dakr@kernel.org> (raw)
In-Reply-To: <20261112005455.1224352-1-dakr@kernel.org>
The driver model uses native Rust lifetimes to let driver data retain
device resources and a Device<Bound> reference for the duration of the
binding. Both remain accessible from the destructor, so a separate
unbind() callback is no longer needed.
Remove auxiliary::Driver::unbind() and the adapter's remove callback and
document that device teardown belongs in Drop or PinnedDrop.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
rust/kernel/auxiliary.rs | 34 ++++------------------------------
1 file changed, 4 insertions(+), 30 deletions(-)
diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
index 9d3de109b381..d4618c92181f 100644
--- a/rust/kernel/auxiliary.rs
+++ b/rust/kernel/auxiliary.rs
@@ -64,7 +64,6 @@ unsafe fn register(
unsafe {
(*adrv.get()).name = name.as_char_ptr();
(*adrv.get()).probe = Some(Self::probe_callback);
- (*adrv.get()).remove = Some(Self::remove_callback);
(*adrv.get()).id_table = T::ID_TABLE.as_ptr();
}
@@ -105,21 +104,6 @@ extern "C" fn probe_callback(
Ok(0)
})
}
-
- extern "C" fn remove_callback(adev: *mut bindings::auxiliary_device) {
- // SAFETY: The auxiliary bus only ever calls the probe callback with a valid pointer to a
- // `struct auxiliary_device`.
- //
- // INVARIANT: `adev` is valid for the duration of `remove_callback()`.
- let adev = unsafe { &*adev.cast::<Device<device::CoreInternal<'_>>>() };
-
- // 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::Data<'_>>>`.
- let data = unsafe { adev.as_ref().drvdata_borrow::<T::Data<'_>>() };
-
- T::unbind(adev, data);
- }
}
/// Declares a kernel module that exposes a single auxiliary driver.
@@ -205,6 +189,10 @@ pub trait Driver {
type IdInfo: 'static;
/// The type of the driver's bus device private data.
+ ///
+ /// Device teardown should be performed in [`Drop`] or [`PinnedDrop`](pin_init::PinnedDrop)
+ /// for this type. The `'bound` lifetime allows the data to retain device resources and a
+ /// [`Device<device::Bound>`] reference for use during teardown.
type Data<'bound>: Send + 'bound;
/// The table of device ids supported by the driver.
@@ -217,20 +205,6 @@ fn probe<'bound>(
dev: &'bound Device<device::Core<'_>>,
id_info: &'bound Self::IdInfo,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound;
-
- /// 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 `Drop`.
- fn unbind<'bound>(dev: &'bound Device<device::Core<'_>>, this: Pin<&Self::Data<'bound>>) {
- let _ = (dev, this);
- }
}
/// The auxiliary device representation.
--
2.56.0
next prev parent reply other threads:[~2026-11-12 1:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 0:52 [PATCH 0/7] rust: treewide: remove driver unbind callbacks Danilo Krummrich
2026-11-12 0:52 ` [PATCH 1/7] rust: pci: remove the unbind() callback Danilo Krummrich
2026-11-12 0:52 ` [PATCH 2/7] rust: platform: " Danilo Krummrich
2026-11-12 0:52 ` Danilo Krummrich [this message]
2026-11-12 0:52 ` [PATCH 4/7] rust: serdev: " Danilo Krummrich
2026-11-12 0:52 ` [PATCH 5/7] rust: i2c: " Danilo Krummrich
2026-11-12 0:53 ` [PATCH 6/7] rust: usb: remove the disconnect() callback Danilo Krummrich
2026-11-12 0:53 ` [PATCH 7/7] rust: driver: document teardown through destructors 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=20261112005455.1224352-4-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david.m.ertman@intel.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=igor.korotin@linux.dev \
--cc=iweiny@kernel.org \
--cc=johan@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®