]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
ls-tree: Do not read Primary Bus Number for PCI Bridges from PCI config space
authorPali Rohár <pali@kernel.org>
Mon, 17 Apr 2023 22:31:10 +0000 (00:31 +0200)
committerPali Rohár <pali@kernel.org>
Sat, 29 Apr 2023 12:14:58 +0000 (14:14 +0200)
For PCIe devices of PCI Bridge type is Primary Bus Number not used and the
default value is 0. PCIe devices capture their Bus and Device numbers
automatically from PCIe TLP packets.

Instead of Primary Bus Number use Device Number because zero value confuse
tree building algorithm. Existing code already expects that Device Number
of PCI Bridge is already set to Primary Bus Number.

ls-tree.c

index 72ac390dee137fedac516e8138c2a3b17951d090..8e01dea18f7882bdfa0a243fe39b341dee18dba2 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -113,15 +113,14 @@ grow_tree(void)
        {
          b = xmalloc(sizeof(struct bridge));
          b->domain = dd->domain;
+         b->primary = dd->bus;
          if (ht == PCI_HEADER_TYPE_BRIDGE)
            {
-             b->primary = get_conf_byte(d, PCI_PRIMARY_BUS);
              b->secondary = get_conf_byte(d, PCI_SECONDARY_BUS);
              b->subordinate = get_conf_byte(d, PCI_SUBORDINATE_BUS);
            }
          else
            {
-             b->primary = get_conf_byte(d, PCI_CB_PRIMARY_BUS);
              b->secondary = get_conf_byte(d, PCI_CB_CARD_BUS);
              b->subordinate = get_conf_byte(d, PCI_CB_SUBORDINATE_BUS);
            }