Commit ceb928be authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bjorn Helgaas

PCI: Document pci_bus_for_each_resource()

There might be confusion about why pci_bus_for_each_resource() uses
Logical OR. Document the entire macro and explain how it works and why the
conditional needs to be like that.

Link: https://lore.kernel.org/r/20230330162434.35055-5-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 09cc9006
......@@ -1444,6 +1444,26 @@ int devm_request_pci_bus_resources(struct device *dev,
/* Temporary until new and working PCI SBR API in place */
int pci_bridge_secondary_bus_reset(struct pci_dev *dev);
/**
* pci_bus_for_each_resource - iterate over PCI bus resources
* @bus: the PCI bus
* @res: pointer to the current resource
* @i: index of the current resource
*
* Iterate over PCI bus resources. The first part is to go over PCI bus
* resource array, which has at most the %PCI_BRIDGE_RESOURCE_NUM entries.
* After that continue with the separate list of the additional resources,
* if not empty. That's why the Logical OR is being used.
*
* Possible usage:
*
* struct pci_bus *bus = ...;
* struct resource *res;
* unsigned int i;
*
* pci_bus_for_each_resource(bus, res, i)
* pr_info("PCI bus resource[%u]: %pR\n", i, res);
*/
#define pci_bus_for_each_resource(bus, res, i) \
for (i = 0; \
(res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment