summaryrefslogtreecommitdiff
path: root/include/linux/pci.h
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-03-30 19:24:31 +0300
committerBjorn Helgaas <bhelgaas@google.com>2023-04-04 18:47:11 +0300
commitceb928be5cab32043f230bcb1adeb0a9a9b8f0f2 (patch)
tree1b9e8f0535db2694b894ff577cffca609839f43b /include/linux/pci.h
parent09cc900632400079619e9154604fd299c2cc9a5a (diff)
downloadlinux-ceb928be5cab32043f230bcb1adeb0a9a9b8f0f2.tar.xz
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.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2234ef961bfe..db3155562320 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -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; \