]> mj.ucw.cz Git - pciutils.git/commitdiff
Tree: Detect bridges properly
authorMartin Mares <mj@ucw.cz>
Sun, 12 Aug 2018 09:13:05 +0000 (11:13 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 12 Aug 2018 10:46:16 +0000 (12:46 +0200)
Previously, only PCI_CLASS_BRIDGE_PCI was considered, which excluded
CardBus bridges. We now accept anything of the base class "bridge"
with the proper header type.

Also added a bunch of debugging messages.

ls-tree.c

index dbb65eb3f633b96ae9801b0c1367df2cdb457f26..8ce9b4faf40272b6724a9188f4dd8eb9c64349a7 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -76,13 +76,14 @@ grow_tree(void)
   last_br = &host_bridge.chain;
   for (d=first_dev; d; d=d->next)
     {
-      word class = d->dev->device_class;
+      struct pci_dev *dd = d->dev;
+      word class = dd->device_class;
       byte ht = get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f;
-      if (class == PCI_CLASS_BRIDGE_PCI &&
+      if ((class >> 8) == PCI_BASE_CLASS_BRIDGE &&
          (ht == PCI_HEADER_TYPE_BRIDGE || ht == PCI_HEADER_TYPE_CARDBUS))
        {
          b = xmalloc(sizeof(struct bridge));
-         b->domain = d->dev->domain;
+         b->domain = dd->domain;
          if (ht == PCI_HEADER_TYPE_BRIDGE)
            {
              b->primary = get_conf_byte(d, PCI_PRIMARY_BUS);
@@ -101,6 +102,9 @@ grow_tree(void)
          b->first_bus = NULL;
          b->br_dev = d;
          d->bridge = b;
+         pacc->debug("Tree: bridge %04x:%02x:%02x.%d: %02x -> %02x-%02x\n",
+           dd->domain, dd->bus, dd->dev, dd->func,
+           b->primary, b->secondary, b->subordinate);
        }
     }
   *last_br = NULL;