[PATCH 2/2] rust: platform: remove TryFrom<&Device> implementation for &platform::Device

From: Nicolás Antinori

Date: Mon Oct 19 2026 - 12:43:03 EST


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@xxxxxxxxx>
Closes: https://github.com/Rust-for-Linux/linux/issues/1264
Signed-off-by: Nicolás Antinori <nico.antinori.7@xxxxxxxxx>
---
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