PCI: Add for_each_pci_bridge() helper

The following pattern is often used:

  list_for_each_entry(dev, &bus->devices, bus_list) {
    if (pci_is_bridge(dev)) {
      ...
    }
  }

Add a for_each_pci_bridge() helper to make that code easier to write and
read by reducing indentation level.  It also saves one or few lines of code
in each occurrence.

Convert PCI core parts here at the same time.

Signed-off-by: Andy Shevchenko <[email protected]>
[bhelgaas: fold in http://lkml.kernel.org/r/[email protected]]
Signed-off-by: Bjorn Helgaas <[email protected]>
This commit is contained in:
Andy Shevchenko 2017-10-20 15:38:54 -05:00 • committed by Bjorn Helgaas
commit 24a0c654d7
8 changed files with 23 additions and 32 deletions

View file

@ -77,9 +77,8 @@ int __ref cb_alloc(struct pcmcia_socket *s)
max = bus->busn_res.start;
for (pass = 0; pass < 2; pass++)
list_for_each_entry(dev, &bus->devices, bus_list)
if (pci_is_bridge(dev))
max = pci_scan_bridge(bus, dev, max, pass);
for_each_pci_bridge(dev, bus)
max = pci_scan_bridge(bus, dev, max, pass);
/*
* Size all resources below the CardBus controller.