[PATCH 3/4] rust: serdev: document `PrivateData::active`

From: Markus Probst

Date: Sat Jul 18 2026 - 07:38:51 EST


Gary pointed out that it isn't clear for what the mutex is used for,
thus adding documentation comments for it.

Suggested-by: Gary Guo <gary@xxxxxxxxxxx>
Link: https://lore.kernel.org/rust-for-linux/DK0SX3P5K1J6.1OV4ETJMXW83R@xxxxxxxxxxx/
Signed-off-by: Markus Probst <markus.probst@xxxxxxxxx>
---
rust/kernel/serdev.rs | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/rust/kernel/serdev.rs b/rust/kernel/serdev.rs
index 79d61c6ceeec..3556fe066ace 100644
--- a/rust/kernel/serdev.rs
+++ b/rust/kernel/serdev.rs
@@ -132,6 +132,23 @@ pub struct PrivateData<'bound, T: Driver> {
#[pin]
driver: UnsafeCell<MaybeUninit<T::Data<'bound>>>,
open: UnsafeCell<bool>,
+ /// Whether `receive_buf_callback` is allowed to call `Driver::receive_buf`.
+ ///
+ /// If locked, the receive_buf_callback will be blocked on data receival.
+ /// This is the case while the driver is being probed or while [`PrivateData`] is being dropped.
+ /// This is necessary, because we need to open the serdev device before the driver has been
+ /// probed in order to allow it to be configured, which allows [`Adapter::receive_buf_callback`]
+ /// to be called. Thus we need to block data until probe completes and the driver data becomes
+ /// initialized.
+ ///
+ /// If unlocked and true, the receive_buf_callback will forward the data to
+ /// `Driver::receive_buf`. This is the normal state of operation.
+ ///
+ /// If unlocked and false, the receive_buf_callback will throw away the data.
+ /// This is only the case, if the serdev device is open and
+ /// - the driver returned an error in probe
+ /// or
+ /// - the driver data already has been dropped, because it was unbound.
#[pin]
active: Mutex<bool>,
}

--
2.54.0