Re: [PATCH v4 3/3] rust: pci: provide access to PCI Vendor values
From: Danilo Krummrich
Date: Wed Aug 20 2025 - 07:56:30 EST
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.