powerpc/pci: convert to use for_each_pci_bridge() helper
PATCH v2 1/2 powerpc/pci: convert to use for_each_pci_bridge() helper
...which makes code slightly cleaner.
Requires: d43f59ce6c50 ("PCI: Add for_each_pci_bridge() helper")
--- arch/powerpc/kernel/pci-hotplug.c | 7 ++----- arch/powerpc/kernel/pci_of_scan.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)
arch/powerpc/kernel/pci-hotplug.c +2 -5
@@ -134,11 +134,8 @@ void pci_hp_add_devices(struct pci_bus *bus)pcibios_setup_bus_devices (bus); 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); } }pcibios_finish_adding_to_bus (bus);
arch/powerpc/kernel/pci_of_scan.c +2 -5
@@ -369,11 +369,8 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus,pcibios_setup_bus_devices (bus);/* Now scan child busses */ -list_for_each_entry (dev, &bus->devices, bus_list) { -if (pci_is_bridge (dev)) { -of_scan_pci_bridge (dev); - } - } +for_each_pci_bridge (dev, bus) +of_scan_pci_bridge (dev); }/**
Signature · 1 line
2.14.2
PATCH v2 2/2 powerpc/pci: Unroll two pass loop when scanning bridges
The current scanning code is really hard to understand because it calls the same function in a loop where pass value is changed without any comments explaining it:
for (pass = 0; pass < 2; pass++)
for_each_pci_bridge(dev, bus)
max = pci_scan_bridge(bus, dev, max, pass);Unfamiliar reader cannot tell easily what is the purpose of this loop without looking at internals of pci_scan_bridge().
In order to make this bit easier to understand, open-code the loop in pci_scan_child_bus() and pci_hp_add_bridge() with added comments.
No functional changes intended.
--- arch/powerpc/kernel/pci-hotplug.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/powerpc/kernel/pci-hotplug.c +12 -5
@@ -104,7 +104,7 @@ EXPORT_SYMBOL_GPL(pci_hp_remove_devices);*/ void pci_hp_add_devices (struct pci_bus *bus) { -int slotno, mode, pass, max; +int slotno, mode, max;struct pci_dev *dev;struct pci_controller *phb;struct device_node *dn =pci_bus_to_OF_node (bus);
@@ -133,10 +133,17 @@ void pci_hp_add_devices(struct pci_bus *bus)pci_scan_slot (bus,PCI_DEVFN (slotno,0 ));pcibios_setup_bus_devices (bus); max = bus->busn_res.start; -for (pass =0 ; pass <2 ; pass++) { -for_each_pci_bridge (dev, bus) - max =pci_scan_bridge (bus, dev, max, pass); - } +/* +* Scan bridges that are already configured. We don't touch +* them unless they are misconfigured (which will be done in +* the second scan below). +*/ +for_each_pci_bridge (dev, bus) + max =pci_scan_bridge (bus, dev, max,0 ); + +/* Scan bridges that need to be reconfigured */ +for_each_pci_bridge (dev, bus) + max =pci_scan_bridge (bus, dev, max,1 ); }pcibios_finish_adding_to_bus (bus); }
Signature · 1 line
2.14.2
Re: [PATCH v2 2/2] powerpc/pci: Unroll two pass loop when scanning bridges
Quoted 11 lines · Andy Shevchenko
The current scanning code is really hard to understand because it calls the same function in a loop where pass value is changed without any comments explaining it:
for (pass = 0; pass < 2; pass++) for_each_pci_bridge(dev, bus) max = pci_scan_bridge(bus, dev, max, pass);Unfamiliar reader cannot tell easily what is the purpose of this loop without looking at internals of
pci_scan_bridge().
Quoted 6 lines
In order to make this bit easier to understand, open-code the loop in
pci_scan_child_bus()andpci_hp_add_bridge()with added comments.No functional changes intended.
Cc Mika Westerberg <[email protected]>
Quoted 3 lines · Andy Shevchenko
...which makes code slightly cleaner.
Requires:
d43f59ce6c50("PCI: Addfor_each_pci_bridge()helper")
Requires: 24a0c654d7d6 ("PCI: Add for_each_pci_bridge() helper")
(My fault, I rebased that commit before sending it to Linus.)
Quoted 1 line
Acked-by Michael Ellerman <[email protected]>
These don't depend on anything in the PCI core, so they could go either via my tree or the powerpc tree. Since you acked this, Michael, I corrected the SHA1 above and put these both on my pci/misc branch.
If you pick them up, let me know and I'll drop them from my tree.
Quoted 45 lines
Signed-off-by Andy Shevchenko <[email protected]>--- arch/powerpc/kernel/pci-hotplug.c | 7 ++----- arch/powerpc/kernel/pci_of_scan.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)arch/powerpc/kernel/pci-hotplug.c +2
-5@@ -134,11 +134,8 @@ void pci_hp_add_devices(struct pci_bus *bus)pcibios_setup_bus_devices (bus); 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); } }pcibios_finish_adding_to_bus (bus);arch/powerpc/kernel/pci_of_scan.c +2
-5@@ -369,11 +369,8 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus,pcibios_setup_bus_devices (bus);/* Now scan child busses */ -list_for_each_entry (dev, &bus->devices, bus_list) { -if (pci_is_bridge (dev)) { -of_scan_pci_bridge (dev); - } - } +for_each_pci_bridge (dev, bus) +of_scan_pci_bridge (dev); }/** Signature · 1 line
2.14.2
Michael Ellerman
reviewerQuoted 7 lines · Bjorn Helgaas
Quoted 3 lines · Andy Shevchenko
...which makes code slightly cleaner.
Requires:
d43f59ce6c50("PCI: Addfor_each_pci_bridge()helper")Requires:
24a0c654d7d6("PCI: Addfor_each_pci_bridge()helper")
Quoted 8 lines
(My fault, I rebased that commit before sending it to Linus.)
Quoted 1 line
Acked-by Michael Ellerman <[email protected]>These don't depend on anything in the PCI core, so they could go either via my tree or the powerpc tree. Since you acked this, Michael, I corrected the SHA1 above and put these both on my pci/misc branch.
Thanks. That's aiming for 4.16 I assume?
cheers
Quoted 11 lines · Michael Ellerman
Quoted 9 lines · Bjorn Helgaas
Quoted 3 lines · Andy Shevchenko
...which makes code slightly cleaner.
Requires:
d43f59ce6c50("PCI: Addfor_each_pci_bridge()helper")Requires:
24a0c654d7d6("PCI: Addfor_each_pci_bridge()helper")(My fault, I rebased that commit before sending it to Linus.)
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Acked-by Michael Ellerman <[email protected]>These don't depend on anything in the PCI core, so they could go either via my tree or the powerpc tree. Since you acked this, Michael, I corrected the SHA1 above and put these both on my pci/misc branch.
Thanks. That's aiming for 4.16 I assume?
Right.