STRUCT PCI_DEVICE_ID(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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, or PCI_ANY_ID if you're feeling "any vendor will do" energy ✨
  • device β€” the Device ID to match, or PCI_ANY_ID for the same wildcard situation πŸ’…
  • subvendor β€” the Subsystem vendor ID to match, or PCI_ANY_ID πŸŽ€
  • subdevice β€” the Subsystem device ID to match, or PCI_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 or include/linux/pci_ids.h πŸ“š but ngl, most drivers literally do not need to specify class/class_mask at all, because vendor/device is normally plenty. slay, keep it simple πŸ’–
  • class_mask β€” limits which sub-fields of the class field actually get compared. if you want to see it in the wild, check drivers/scsi/sym53c8xx_2/ for an example of usage πŸ”
  • driver_data β€” data private to the driver. most drivers don't need to use the driver_data field at all, fr. best practice? use driver_data as 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 when dev->driver_override is 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