From: Gary Guo <gary@garyguo.net>
To: "Benno Lossin" <lossin@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"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: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Gary Guo <gary@garyguo.net>
Subject: [PATCH 2/4] rust: devres: use `cast_pin_init` instead of manual reimplementation
Date: Wed, 22 Jul 2026 19:50:16 +0100 [thread overview]
Message-ID: <20260722-merge-init-v1-2-d4594de76538@garyguo.net> (raw)
In-Reply-To: <20260722-merge-init-v1-0-d4594de76538@garyguo.net>
Remove the manual type-casting which is already available as
`cast_pin_init`.
Signed-off-by: Gary Guo <gary@garyguo.net>
---
rust/kernel/devres.rs | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
index ebb5c19e851e..aecc8906de2c 100644
--- a/rust/kernel/devres.rs
+++ b/rust/kernel/devres.rs
@@ -435,11 +435,7 @@ pub unsafe fn new<'a, E>(
// SAFETY: The caller guarantees the data is valid for the device's full bound scope.
// Lifetimes do not affect layout, so F::Of<'a> and F::Of<'static> have identical
// representation; casting the slot pointer is sound.
- let data = unsafe {
- pin_init::pin_init_from_closure::<F::Of<'static>, E>(move |slot| {
- data.__pinned_init(slot.cast())
- })
- };
+ let data = unsafe { pin_init::cast_pin_init(data) };
Ok(Self(Devres::new(dev, data)?))
}
--
2.54.0
next prev parent reply other threads:[~2026-07-22 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 18:50 [PATCH 0/4] rust: pin-init: merge `__init` and `__pinned_init` Gary Guo
2026-07-22 18:50 ` [PATCH 1/4] rust: pin-init: merge `__pinned_init` and `__init` Gary Guo
2026-07-22 18:50 ` Gary Guo [this message]
2026-07-22 18:50 ` [PATCH 3/4] rust: treewide: replace `__pinned_init` with `__init` Gary Guo
2026-07-22 18:50 ` [PATCH 4/4] rust: pin-init: remove `__pinned_init` method for `cfg(kernel)` Gary Guo
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=20260722-merge-init-v1-2-d4594de76538@garyguo.net \
--to=gary@garyguo.net \
--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=linux-kernel@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