Re: [PATCH 2/8] rust: pci: add is_physfn(), to check for PFs

Peter Colberg
2025-12-09T18:24:26Z

On Sun, Dec 07, 2025 at 01:35:29AM -0500, Joel Fernandes wrote:
> On Wed, Nov 19, 2025 at 05:19:06PM -0500, Peter Colberg wrote:
> > Add a method to check if a PCI device is a Physical Function (PF).
> >
> > Signed-off-by: Peter Colberg <pcolberg@redhat.com>
> > ---
> > rust/kernel/pci.rs | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
> > index c20b8daeb7aadbef9f6ecfc48c972436efac9a08..814990d386708fe2ac652ccaa674c10a6cf390cb 100644
> > --- a/rust/kernel/pci.rs
> > +++ b/rust/kernel/pci.rs
> > @@ -409,6 +409,12 @@ 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 (VF).
>
> nit: s/VF/PF/
>
> also, add #[inline].
>
> With that,
>
> Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

Thanks, done.

Peter

>
> thanks,
>
> - Joel
>
>
>
> > + 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).
> > pub fn is_virtfn(&self) -> bool {
> > // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
> >
> > --
> > 2.51.1
> >
>