Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24a0c654 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bjorn Helgaas
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
[bhelgaas: fold in http://lkml.kernel.org/r/20171013165352.25550-1-andriy.shevchenko@linux.intel.com

]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 3691314a
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -462,18 +462,15 @@ static void enable_slot(struct acpiphp_slot *slot)
	acpiphp_rescan_slot(slot);
	max = acpiphp_max_busnr(bus);
	for (pass = 0; pass < 2; pass++) {
		list_for_each_entry(dev, &bus->devices, bus_list) {
		for_each_pci_bridge(dev, bus) {
			if (PCI_SLOT(dev->devfn) != slot->device)
				continue;

			if (pci_is_bridge(dev)) {
			max = pci_scan_bridge(bus, dev, max, pass);
			if (pass && dev->subordinate) {
				check_hotplug_bridge(slot, dev);
				pcibios_resource_survey_bus(dev->subordinate);
					__pci_bus_size_bridges(dev->subordinate,
							       &add_list);
				}
				__pci_bus_size_bridges(dev->subordinate, &add_list);
			}
		}
	}
+2 −5
Original line number Diff line number Diff line
@@ -286,14 +286,11 @@ int cpci_configure_slot(struct slot *slot)
	}
	parent = slot->dev->bus;

	list_for_each_entry(dev, &parent->devices, bus_list) {
		if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn))
			continue;
		if (pci_is_bridge(dev))
	for_each_pci_bridge(dev, parent) {
		if (PCI_SLOT(dev->devfn) == PCI_SLOT(slot->devfn))
			pci_hp_add_bridge(dev);
	}


	pci_assign_unassigned_bridge_resources(parent->self);

	pci_bus_add_devices(parent);
+2 −3
Original line number Diff line number Diff line
@@ -60,8 +60,7 @@ int pciehp_configure_device(struct slot *p_slot)
		goto out;
	}

	list_for_each_entry(dev, &parent->devices, bus_list)
		if (pci_is_bridge(dev))
	for_each_pci_bridge(dev, parent)
		pci_hp_add_bridge(dev);

	pci_assign_unassigned_bridge_resources(bridge);
+2 −4
Original line number Diff line number Diff line
@@ -61,10 +61,8 @@ int shpchp_configure_device(struct slot *p_slot)
		goto out;
	}

	list_for_each_entry(dev, &parent->devices, bus_list) {
		if (PCI_SLOT(dev->devfn) != p_slot->device)
			continue;
		if (pci_is_bridge(dev))
	for_each_pci_bridge(dev, parent) {
		if (PCI_SLOT(dev->devfn) == p_slot->device)
			pci_hp_add_bridge(dev);
	}

+2 −4
Original line number Diff line number Diff line
@@ -2421,10 +2421,8 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
	}

	for (pass = 0; pass < 2; pass++)
		list_for_each_entry(dev, &bus->devices, bus_list) {
			if (pci_is_bridge(dev))
		for_each_pci_bridge(dev, bus)
			max = pci_scan_bridge(bus, dev, max, pass);
		}

	/*
	 * Make sure a hotplug bridge has at least the minimum requested
Loading