From: Markus Probst <markus.probst@posteo.de>
To: Mohamed Osama <mohamed.osama189110@gmail.com>, ojeda@kernel.org
Cc: boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
tmgross@umich.edu, dakr@kernel.org,
daniel.almeida@collabora.com, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev, longman@redhat.com,
lyude@redhat.com, linux-block@vger.kernel.org,
linux-serial@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] rust: serdev: use DropGuard
Date: Sat, 10 Oct 2026 21:30:04 +0000 [thread overview]
Message-ID: <19c329dfc42ac74b8ca7ce9a4b0f3f58b5a57fec.camel@posteo.de> (raw)
In-Reply-To: <20260927104528.103881-4-mohamed.osama189110@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2423 bytes --]
On Sun, 2026-09-27 at 13:45 +0300, Mohamed Osama wrote:
> Replace the ScopeGuard usage in the serial device bus implementation
> with DropGuard.
>
> Use DropGuard::dismiss() when ownership of the private data needs to be
> transferred without running the cleanup callback.
>
> Signed-off-by: Mohamed Osama <mohamed.osama189110@gmail.com>
> ---
> rust/kernel/serdev.rs | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/rust/kernel/serdev.rs b/rust/kernel/serdev.rs
> index 17ca504b7f8d..dd43b159b461 100644
> --- a/rust/kernel/serdev.rs
> +++ b/rust/kernel/serdev.rs
> @@ -13,6 +13,7 @@
> to_result,
> VTABLE_DEFAULT_ERROR, //
> },
> + mem::DropGuard,
> new_mutex,
> of,
> prelude::*,
> @@ -21,10 +22,7 @@
> Mutex, //
> },
> time::Jiffies,
> - types::{
> - Opaque,
> - ScopeGuard, //
> - }, //
> + types::Opaque, //
> };
>
> use core::{
> @@ -174,7 +172,7 @@ extern "C" fn probe_callback(sdev: *mut bindings::serdev_device) -> kernel::ffi:
> }))?;
> // SAFETY: We just set drvdata to `PrivateData<'_, T>`.
> let private_data = unsafe { sdev.as_ref().drvdata_borrow::<PrivateData<'_, T>>() };
> - let private_data = ScopeGuard::new_with_data(private_data, |_| {
> + let private_data = DropGuard::new(private_data, |_| {
> // SAFETY: We just set drvdata to `PrivateData<'_, T>`.
> drop(unsafe { sdev.as_ref().drvdata_obtain::<PrivateData<'_, T>>() });
> });
> @@ -204,7 +202,7 @@ extern "C" fn probe_callback(sdev: *mut bindings::serdev_device) -> kernel::ffi:
> drop(active);
>
> result.map(|()| {
> - private_data.dismiss();
> + DropGuard::dismiss(private_data);
> 0
> })
> })
I am surprised to not find myself on CC. I only look loosly on the
linux-serial mailing list, so please add me to CC.
This patch will be redundant once
https://lore.kernel.org/linux-serial/20260930-rust_serdev_probe_refactor-v3-4-d1b6e77135e0@posteo.de/
get merged. Not sure if it gets merged this cycle though.
Also I am not sure on which base this should be applied to?
Applying to v7.3-rc6 or next-20261009 fails.
Thanks
- Markus Probst
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 870 bytes --]
next prev parent reply other threads:[~2026-10-10 21:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Dch07wH15t-1WtaVQW4vdfmtJuwC_4-JLvrWSB8Pk4vfEHO6mQk1FpYG-tCYBllTB3RbpOXpdyNZp84w4PFl1A==@protonmail.internalid>
2026-09-27 10:45 ` [PATCH v4 0/4] rust: introduce DropGuard Mohamed Osama
2026-09-27 10:45 ` [PATCH 1/4] rust: mem: add DropGuard Mohamed Osama
2026-09-27 10:45 ` [PATCH 2/4] rust: block: gen_disk: use DropGuard Mohamed Osama
2026-09-27 10:45 ` [PATCH 3/4] rust: serdev: " Mohamed Osama
2026-10-10 21:30 ` Markus Probst [this message]
2026-09-27 10:45 ` [PATCH 4/4] rust: sync: lock: " Mohamed Osama
2026-09-28 9:03 ` Boqun Feng
2026-09-28 9:48 ` [PATCH v4 0/4] rust: introduce DropGuard Andreas Hindborg
2026-09-28 9:50 ` Andreas Hindborg
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=19c329dfc42ac74b8ca7ce9a4b0f3f58b5a57fec.camel@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=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=longman@redhat.com \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mohamed.osama189110@gmail.com \
--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
all inboxes | Powered by JetHome®