File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,7 +87,9 @@ impl<T: Driver + 'static> Adapter<T> {
8787 // SAFETY: `remove_callback` is only ever called after a successful call to
8888 // `probe_callback`, hence it's guaranteed that `Device::set_drvdata()` has been called
8989 // and stored a `Pin<KBox<T>>`.
90- drop ( unsafe { adev. as_ref ( ) . drvdata_obtain :: < T > ( ) } ) ;
90+ let data = unsafe { adev. as_ref ( ) . drvdata_obtain :: < T > ( ) } ;
91+
92+ T :: unbind ( adev, data. as_ref ( ) ) ;
9193 }
9294}
9395
@@ -187,6 +189,20 @@ pub trait Driver {
187189 ///
188190 /// Called when an auxiliary device is matches a corresponding driver.
189191 fn probe ( dev : & Device < device:: Core > , id_info : & Self :: IdInfo ) -> impl PinInit < Self , Error > ;
192+
193+ /// Auxiliary driver unbind.
194+ ///
195+ /// Called when a [`Device`] is unbound from its bound [`Driver`]. Implementing this callback
196+ /// is optional.
197+ ///
198+ /// This callback serves as a place for drivers to perform teardown operations that require a
199+ /// `&Device<Core>` or `&Device<Bound>` reference. For instance, drivers may try to perform I/O
200+ /// operations to gracefully tear down the device.
201+ ///
202+ /// Otherwise, release operations for driver resources should be performed in `Self::drop`.
203+ fn unbind ( dev : & Device < device:: Core > , this : Pin < & Self > ) {
204+ let _ = ( dev, this) ;
205+ }
190206}
191207
192208/// The auxiliary device representation.
You can’t perform that action at this time.
0 commit comments