From: Markus Probst <markus.probst@posteo.de>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>
Cc: linux-serial@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org,
Markus Probst <markus.probst@posteo.de>
Subject: [PATCH 3/4] rust: serdev: document `PrivateData::active`
Date: Sat, 18 Jul 2026 11:36:56 +0000 [thread overview]
Message-ID: <20260718-rust_serdev_fixes-v1-3-35433b6dce0f@posteo.de> (raw)
In-Reply-To: <20260718-rust_serdev_fixes-v1-0-35433b6dce0f@posteo.de>
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@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/DK0SX3P5K1J6.1OV4ETJMXW83R@garyguo.net/
Signed-off-by: Markus Probst <markus.probst@posteo.de>
---
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
next prev parent reply other threads:[~2026-07-18 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 11:36 [PATCH 0/4] rust: serdev: trivial fixes Markus Probst
2026-07-18 11:36 ` [PATCH 1/4] rust: serdev: fix typo in rustdoc Markus Probst
2026-07-18 11:36 ` [PATCH 2/4] rust: serdev: mark small functions as `#[inline]` Markus Probst
2026-07-18 11:36 ` Markus Probst [this message]
2026-07-18 11:36 ` [PATCH 4/4] rust: serdev: remove `serdev::Timeout` Markus Probst
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=20260718-rust_serdev_fixes-v1-3-35433b6dce0f@posteo.de \
--to=markus.probst@posteo.de \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@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