[PATCH 1/2] rust: pci: remove TryFrom<&Device> implementation for &pci::Device
From: Nicolás Antinori
Date: Mon Oct 19 2026 - 14:26:45 EST
Remove the `TryFrom<&device::Device<Ctx>>` implementation for
`&Device<Ctx>` since it has no remaining users.
Fixes: 7edc491f6fca ("drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter")
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/pci.rs | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 769d01d23429..0e9455fd544d 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -6,7 +6,6 @@
use crate::{
bindings,
- container_of,
device,
device_id::{
RawDeviceId,
@@ -535,26 +534,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_pci(dev.as_raw()) } {
- return Err(EINVAL);
- }
-
- // SAFETY: We've just verified that the bus type of `dev` equals `bindings::pci_bus_type`,
- // hence `dev` must be embedded in a valid `struct pci_dev` as guaranteed by the
- // corresponding C code.
- let pdev = unsafe { container_of!(dev.as_raw(), bindings::pci_dev, dev) };
-
- // SAFETY: `pdev` is a valid pointer to a `struct pci_dev`.
- 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