[PATCH v4 3/3] rust: pci: provide access to PCI Vendor values

Danilo Krummrich dakr at kernel.org
Wed Aug 20 11:56:12 UTC 2025


On Wed Aug 20, 2025 at 5:08 AM CEST, John Hubbard wrote:
>  impl Device {
> -    /// Returns the PCI vendor ID.
> -    pub fn vendor_id(&self) -> u16 {
> +    /// Returns the PCI vendor ID as a validated Vendor.
> +    /// Returns an error if the vendor ID is not recognized.
> +    pub fn vendor_id(&self) -> Result<Vendor> {
>          // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
> -        unsafe { (*self.as_raw()).vendor }
> +        let vendor_id = unsafe { (*self.as_raw()).vendor };
> +        Vendor::try_from(vendor_id as u32)
>      }

Same as for Class, I think we just want Vendor::UNKNOWN.


More information about the Nouveau mailing list