pci_bus_for_each_resource(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 πŸ”₯

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 page pci_bus_for_each_resource(9) of the Kernel API Manual. periodt. πŸ’€ 🌸 πŸ“ πŸ’–
πŸ“¦ where this page comes from