Re: [PATCH v3 05/10] rust: pci: add num_vf(), to return number of VFs
From: Danilo Krummrich
Date: Wed Sep 30 2026 - 07:22:26 EST
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").
> + // SAFETY: `self.as_raw()` is valid and this call runs in the PCI core callback context.
> + unsafe { bindings::pci_num_vf(self.as_raw()) }
> + }
> +}