From: "Nicolás Antinori" <nico.antinori.7@gmail.com>
To: Danilo Krummrich <dakr@kernel.org>,
Georgios Androutsopoulos <georgeandrout13@gmail.com>
Cc: "Nicolás Antinori" <nico.antinori.7@gmail.com>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Boqun Feng" <boqun@kernel.org>,
"Brigham Campbell" <me@brighamcampbell.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Gary Guo" <gary@garyguo.net>,
"Jori Koolstra" <jkoolstra@xs4all.nl>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev
Subject: [PATCH 2/2] rust: platform: remove TryFrom<&Device> implementation for &platform::Device
Date: Mon, 19 Oct 2026 13:13:38 -0300 [thread overview]
Message-ID: <9a53f75cf2d607bbcbcf54777e75caf99dcf6318.1792417858.git.nico.antinori.7@gmail.com> (raw)
In-Reply-To: <cover.1792417858.git.nico.antinori.7@gmail.com>
Remove the `TryFrom<&device::Device<Ctx>>` implementation for
`&Device<Ctx>` since it has had no users since its introduction.
Fixes: a38dfd60fe53 ("rust: platform: impl TryFrom<&Device> for &platform::Device")
Reported-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1264
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
---
rust/kernel/platform.rs | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
index ac0a012ae1bb..f49aedcc94b1 100644
--- a/rust/kernel/platform.rs
+++ b/rust/kernel/platform.rs
@@ -7,7 +7,6 @@
use crate::{
acpi,
bindings,
- container_of,
device::{
self,
Bound, //
@@ -557,26 +556,6 @@ fn as_ref(&self) -> &device::Device<Ctx> {
}
}
-impl<Ctx: device::DeviceContext> TryFrom<&device::Device<Ctx>> for &Device<Ctx> {
- type Error = kernel::error::Error;
-
- fn try_from(dev: &device::Device<Ctx>) -> Result<Self, Self::Error> {
- // SAFETY: By the type invariant of `Device`, `dev.as_raw()` is a valid pointer to a
- // `struct device`.
- if !unsafe { bindings::dev_is_platform(dev.as_raw()) } {
- return Err(EINVAL);
- }
-
- // SAFETY: We've just verified that the bus type of `dev` equals
- // `bindings::platform_bus_type`, hence `dev` must be embedded in a valid
- // `struct platform_device` as guaranteed by the corresponding C code.
- let pdev = unsafe { container_of!(dev.as_raw(), bindings::platform_device, dev) };
-
- // SAFETY: `pdev` is a valid pointer to a `struct platform_device`.
- Ok(unsafe { &*pdev.cast() })
- }
-}
-
// SAFETY: A `Device` is always reference-counted and can be released from any thread.
unsafe impl Send for Device {}
--
2.47.3
prev parent reply other threads:[~2026-10-19 16:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 16:13 [PATCH 0/2] remove TryFrom<&Device> implementation for pci and platform Nicolás Antinori
2026-10-19 16:13 ` [PATCH 1/2] rust: pci: remove TryFrom<&Device> implementation for &pci::Device Nicolás Antinori
2026-10-19 18:24 ` Nicolás Antinori
2026-10-19 16:13 ` Nicolás Antinori [this message]
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=9a53f75cf2d607bbcbcf54777e75caf99dcf6318.1792417858.git.nico.antinori.7@gmail.com \
--to=nico.antinori.7@gmail.com \
--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=georgeandrout13@gmail.com \
--cc=jkoolstra@xs4all.nl \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=me@brighamcampbell.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.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®