From f558905d0b843dbb67104f8c2cb17eb40ffe9c7e Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 12 Aug 2018 11:13:05 +0200 Subject: [PATCH] Tree: Detect bridges properly 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ls-tree.c b/ls-tree.c index dbb65eb..8ce9b4f 100644 --- 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; -- 2.39.2