PCI: Introduce pci_dev_for_each_resource()
Instead of open-coding it everywhere introduce a tiny helper that can be used to iterate over each resource of a PCI device, and convert the most obvious users into it. While at it drop doubled empty line before pdev_sort_resources(). No functional changes intended. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230330162434.35055-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
This commit is contained in:
committed by
Bjorn Helgaas
parent
144d204df7
commit
09cc900632
@@ -2002,6 +2002,20 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
|
||||
(pci_resource_end((dev), (bar)) ? \
|
||||
resource_size(pci_resource_n((dev), (bar))) : 0)
|
||||
|
||||
#define __pci_dev_for_each_res0(dev, res, ...) \
|
||||
for (unsigned int __b = 0; \
|
||||
res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES; \
|
||||
__b++)
|
||||
|
||||
#define __pci_dev_for_each_res1(dev, res, __b) \
|
||||
for (__b = 0; \
|
||||
res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES; \
|
||||
__b++)
|
||||
|
||||
#define pci_dev_for_each_resource(dev, res, ...) \
|
||||
CONCATENATE(__pci_dev_for_each_res, COUNT_ARGS(__VA_ARGS__)) \
|
||||
(dev, res, __VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Similar to the helpers above, these manipulate per-pci_dev
|
||||
* driver-specific data. They are really just a wrapper around
|
||||
|
||||
Reference in New Issue
Block a user