Re: [PATCH v3 05/10] rust: pci: add num_vf(), to return number of VFs
From: Zhi Wang
Date: Sat Oct 03 2026 - 13:21:37 EST
On Wed, 30 Sep 2026 13:13:25 +0200
"Danilo Krummrich" <dakr@xxxxxxxxxx> wrote:
> On Wed Sep 30, 2026 at 12:18 PM CEST, Zhi Wang wrote:
> > +impl Device<device::Core<'_>> {
> > + /// Returns the number of Virtual Functions (VF) enabled for a
> > Physical Function (PF).
> > + pub fn num_vf(&self) -> i32 {
>
> For the reasons mentioned in patch 1, I'd make this return u16.
>
> I suggest to do the converstion with
> .try_into().expect("pdev->sriov->num_VFs is u16").
>
Got it. Will fix that in the next respin.
> > + // SAFETY: `self.as_raw()` is valid and this call runs in
> > the PCI core callback context.
> > + unsafe { bindings::pci_num_vf(self.as_raw()) }
> > + }
> > +}