Commit f2a230bd authored by Wei Yang's avatar Wei Yang Committed by Bjorn Helgaas

PCI: Enumerate subordinate buses, not devices, in pci_bus_get_depth()

Normally, on one PCI bus there would be more devices than bridges.  When
calculating the depth of a PCI bus, it would be more time efficient to
enumerating through the child buses instead of the child devices.

Also by doing so, the code seems more self explaining.  Previously, it went
through the devices and checked whether a bridge introduced a child bus or
not, which needs more background knowledge to understand it.

This patch calculates the depth by enumerating the bus hierarchy.
Signed-off-by: default avatarWei Yang <weiyang@linux.vnet.ibm.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 3b2f64d0
...@@ -1300,15 +1300,12 @@ static void pci_bus_dump_resources(struct pci_bus *bus) ...@@ -1300,15 +1300,12 @@ static void pci_bus_dump_resources(struct pci_bus *bus)
static int __init pci_bus_get_depth(struct pci_bus *bus) static int __init pci_bus_get_depth(struct pci_bus *bus)
{ {
int depth = 0; int depth = 0;
struct pci_dev *dev; struct pci_bus *child_bus;
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(child_bus, &bus->children, node){
int ret; int ret;
struct pci_bus *b = dev->subordinate;
if (!b)
continue;
ret = pci_bus_get_depth(b); ret = pci_bus_get_depth(child_bus);
if (ret + 1 > depth) if (ret + 1 > depth)
depth = ret + 1; depth = ret + 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment