Re: [PATCH v3 3/5] rust: pci: make Vendor::from_raw() public
| Newsgroups | org.freedesktop.lists.dri-devel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
> `Vendor::from_raw()` is currently `pub(super)`, so a Vendor can only be > obtained through the named constants generated from the > `PCI_VENDOR_ID_*` defines in `<linux/pci_ids.h>`. A driver therefore > cannot match a device whose vendor ID has no symbolic name. > > Such devices exist. QEMU's "edu" educational device and the legacy > qemu/Bochs stdvga both use vendor ID 0x1234, which is not registered in > `pci_ids.h`. Per the policy stated at the top of that header, IDs are > only added there when shared between multiple drivers; a single-driver > ID is expected to be open-coded in the driver instead. C drivers already > do this -- see `drivers/gpu/drm/tiny/bochs.c`, which matches with a bare > ".vendor = 0x1234". > > The Rust abstraction has no equivalent escape hatch: there is no public > way to express an unregistered vendor. Make `Vendor::from_raw()` public > (and const, so it can be used in the const device-ID tables built by > `pci_device_table!`) so that drivers can construct a Vendor from a raw > ID, matching what C drivers can already do. > > Reviewed-by: Gary Guo <[email protected]> > Reviewed-by: Onur Özkan <[email protected]> > Signed-off-by: Maurice Hieronymus <[email protected]> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3