diff options
author | Wei Yang <weiyang@linux.vnet.ibm.com> | 2013-08-02 05:31:03 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-08-02 18:11:09 -0400 |
commit | f2a230bd4e1ac4b54ec59dc0b2a246bfe3e89ffe (patch) | |
tree | 97ca425d564096d164185bb7277c51b21cd9194e /drivers/pci/setup-bus.c | |
parent | 3b2f64d00c46e1e4e9bd0bb9bb12619adac27a4b (diff) |
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: Wei Yang <weiyang@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/setup-bus.c')
-rw-r--r-- | drivers/pci/setup-bus.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index d254e2379533..6dbe5629c8b4 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1300,15 +1300,12 @@ static void pci_bus_dump_resources(struct pci_bus *bus) | |||
1300 | static int __init pci_bus_get_depth(struct pci_bus *bus) | 1300 | static int __init pci_bus_get_depth(struct pci_bus *bus) |
1301 | { | 1301 | { |
1302 | int depth = 0; | 1302 | int depth = 0; |
1303 | struct pci_dev *dev; | 1303 | struct pci_bus *child_bus; |
1304 | 1304 | ||
1305 | list_for_each_entry(dev, &bus->devices, bus_list) { | 1305 | list_for_each_entry(child_bus, &bus->children, node){ |
1306 | int ret; | 1306 | int ret; |
1307 | struct pci_bus *b = dev->subordinate; | ||
1308 | if (!b) | ||
1309 | continue; | ||
1310 | 1307 | ||
1311 | ret = pci_bus_get_depth(b); | 1308 | ret = pci_bus_get_depth(child_bus); |
1312 | if (ret + 1 > depth) | 1309 | if (ret + 1 > depth) |
1313 | depth = ret + 1; | 1310 | depth = ret + 1; |
1314 | } | 1311 | } |