pci_bus_for_each_resource(9)
π pci_bus_for_each_resource(9) β Kernel API Manual, bestie edition β¨
okay so this is a page from the Kernel API Manual, and it's literally about looping over PCI bus resources. it's giving "for loop but make it kernel" and honestly? we're obsessed. π
πΈ NAME πΈ
pci_bus_for_each_resource β iterate over PCI bus resources π
β SYNOPSIS β
pci_bus_for_each_resource (bus , res , ... );
π¦ ARGUMENTS π¦
busβ the PCI bus. like, the whole vibe you're walking through πresβ pointer to the current resource. this is your main character pointer, it moves as you iterate π...β optional index of the current resource. yes optional, yes it's a whole thing β¨
π DESCRIPTION π
so the way this works: you iterate over PCI bus resources. the first part is to go over the PCI bus resource array β and that array has at most the PCI_BRIDGE_RESOURCE_NUM entries. no cap, at most. π«Ά
after that, you continue with the separate list of the additional resources, if not empty. that's why the Logical OR is being used. iykyk π the || is doing heavy lifting ok
possible usage:
struct pci_bus *bus = ...; struct resource *res; unsigned int i;
// With optional index pci_bus_for_each_resource(bus, res, i)
pr_info("PCI bus resource[u]: pR0, i, res);
// Without index pci_bus_for_each_resource(bus, res)
_do_something_(res);
so cute, so clean, so iconic. copy it exactly, don't come for me about the formatting, that's how the page has it π
π₯ SEE ALSO π₯
- Kernel file
./include/linux/pci.hβ yes, the header, go read it bestie π enum pci_interrupt_pin(9)pci_channel_state_t(9)pci_is_bridge(9)pci_is_vga(9)pci_is_display(9)struct pci_driver(9)PCI_DEVICE(9)PCI_DEVICE_DRIVER_OVERRIDE(9)PCI_DRIVER_OVERRIDE_DEVICE_VFIO(9)PCI_DEVICE_SUB(9)PCI_DEVICE_CLASS(9)PCI_VDEVICE(9)PCI_VDEVICE_SUB(9)PCI_DEVICE_DATA(9)pcie_capability_clear_and_set_word(9)module_pci_driver(9)builtin_pci_driver(9)pci_irq_type(9)pci_irqd_intx_xlate(9)pci_resource_is_io(9)pci_resource_is_mem(9)pci_pcie_cap(9)pci_is_pcie(9)pcie_caps_reg(9)pci_pcie_type(9)pcie_find_root_port(9)pci_vpd_alloc(9)pci_vpd_find_id_string(9)pci_vpd_find_ro_info_keyword(9)pci_vpd_check_csum(9)pci_ari_enabled(9)pci_is_thunderbolt_attached(9)
like, that's the whole friend group, all 32 of them, slay π§ β¨
heads up bestie: this was shipped from./include/linux, dated October 2026, and it's pagepci_bus_for_each_resource(9)of the Kernel API Manual. periodt. π πΈ π π
π¦ 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