[PATCH v3 07/10] rust: pci: add is_physfn(), to check for PFs
Peter Colberg <[email protected]> Tue, 03 Mar 2026 16:15:27 -0500
| Newsgroups | org.kernel.vger.linux-fpga,dev.linux.lists.driver-core,org.freedesktop.lists.dri-devel,org.freedesktop.lists.nouveau,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
Add a method to check if a PCI device is a Physical Function (PF). Reviewed-by: Joel Fernandes <[email protected]> Signed-off-by: Peter Colberg <[email protected]> --- Changes in v2: - Replace VF -> PF in doc comment of is_physfn(). - Add #[inline] to is_physfn(). --- rust/kernel/pci.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index db05641186c3a42922e2b6a463de9c1b099a4673..df39ad3f0d5fd898b034609efb03368f83c2a2e9 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -484,6 +484,13 @@ pub fn resource_start(&self, bar: u32) -> Result<bindings::resource_size_t> { Ok(unsafe { bindings::pci_resource_start(self.as_raw(), bar.try_into()?) }) } + /// Returns `true` if this device is a Physical Function (PF). + #[inline] + pub fn is_physfn(&self) -> bool { + // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`. + unsafe { (*self.as_raw()).is_physfn() != 0 } + } + /// Returns `true` if this device is a Virtual Function (VF). #[inline] pub fn is_virtfn(&self) -> bool { -- 2.53.0