STRUCT PCI_DEVICE_ID(9)
β¨ struct pci_device_id(9) β¨
okay so this is a page from the Kernel API Manual, and bestie, we're about to get into the exact little struct that tells the kernel "hey, this driver works with these devices" π stay with me, it's actually so good.
π NAME π
struct pci_device_id β the PCI device ID structure. that's it. that's the whole vibe. it's the matchmaking profile your driver fills out so the kernel knows which PCI devices it should be paired with π«Ά
πΈ SYNOPSIS πΈ
here's the whole thing, verbatim, no cap:
struct pci_device_id {
__u32 vendor, device;
__u32 subvendor, subdevice;
__u32 class, class_mask;
kernel_ulong_t driver_data;
__u32 override_only;
};
look at her. she's iconic. π
π¦ Members π¦
vendorβ the Vendor ID to match, orPCI_ANY_IDif you're feeling "any vendor will do" energy β¨deviceβ the Device ID to match, orPCI_ANY_IDfor the same wildcard situation πsubvendorβ the Subsystem vendor ID to match, orPCI_ANY_IDπsubdeviceβ the Subsystem device ID to match, orPCI_ANY_IDπΈclassβ the device class, subclass, and "interface" to match. like, the whole class situation. for the full list of classes, go look at Appendix D of the PCI Local Bus Spec orinclude/linux/pci_ids.hπ but ngl, most drivers literally do not need to specifyclass/class_maskat all, becausevendor/deviceis normally plenty. slay, keep it simple πclass_maskβ limits which sub-fields of theclassfield actually get compared. if you want to see it in the wild, checkdrivers/scsi/sym53c8xx_2/for an example of usage πdriver_dataβ data private to the driver. most drivers don't need to use thedriver_datafield at all, fr. best practice? usedriver_dataas an index into a static list of equivalent device types, not as a pointer. yes bestie, index not pointer, write that down ππoverride_onlyβ matches only whendev->driver_overrideis this driver. that's the whole rule, no exceptions π
π SEE ALSO π
- Kernel file
./include/linux/device-id/pci.h
and that's the page!! π§π this came from the kernel source at ./include/linux/device-id, dated October 2026, so if future-you is reading this, hi, hope the kernel is thriving πβ bye bestie, go match some devices π
π₯
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms