[PATCH 7/7] rust: driver: document teardown through destructors

From: Danilo Krummrich

Date: Wed Nov 11 2026 - 20:08:13 EST


The bus driver traits no longer provide an unbind() callback. Remove it
from the example driver trait and describe how the generic registration
infrastructure drops driver data during unbind cleanup.

Document that device teardown belongs in Drop or PinnedDrop, where the
bound device reference and device resources remain accessible.

Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
---
rust/kernel/driver.rs | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
index c9c74c4dde8f..c228d82ace9d 100644
--- a/rust/kernel/driver.rs
+++ b/rust/kernel/driver.rs
@@ -31,14 +31,6 @@
//! dev: &'bound Device<device::Core<'_>>,
//! id_info: &'bound Self::IdInfo,
//! ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound;
-//!
-//! /// Driver unbind (optional).
-//! fn unbind<'bound>(
-//! dev: &'bound Device<device::Core<'_>>,
-//! this: Pin<&Self::Data<'bound>>,
-//! ) {
-//! let _ = (dev, this);
-//! }
//! }
//! ```
//!
@@ -57,9 +49,12 @@
//! [`Device`] infrastructure provides common helpers for this purpose on its
//! [`Device<CoreInternal>`] implementation.
//!
-//! All driver callbacks should provide a reference to the driver's private data. Once the driver
-//! is unbound from the device, the bus abstraction should take back the ownership of the driver's
-//! private data from the corresponding [`Device`] and [`drop`] it.
+//! All driver callbacks should provide a reference to the driver's private data. The generic
+//! [`Registration`] infrastructure drops the driver's private data during unbind cleanup.
+//!
+//! Device teardown should be performed in [`Drop`] or [`PinnedDrop`](pin_init::PinnedDrop) for the
+//! driver's private data. The `'bound` lifetime allows the data to retain device resources and a
+//! [`Device<Bound>`] reference for use during teardown.
//!
//! All driver callbacks should provide a [`Device<Core>`] reference (see also [`device::Core`]).
//!
@@ -98,6 +93,7 @@
//!
//! [`Core`]: device::Core
//! [`Device`]: device::Device
+//! [`Device<Bound>`]: device::Device<device::Bound>
//! [`Device<Core>`]: device::Device<device::Core>
//! [`Device<CoreInternal>`]: device::Device<device::CoreInternal>
//! [`DeviceContext`]: device::DeviceContext
--
2.56.0