]> mj.ucw.cz Git - pciutils.git/commitdiff
PCI-to-PCI bridges were not displayed properly in the tree format.
authorMartin Mares <mj@ucw.cz>
Thu, 19 Mar 1998 15:56:40 +0000 (15:56 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:09:49 +0000 (14:09 +0200)
Eddie, can you check if it still works with multiple host bridges on the Ultra,
please?

ChangeLog
lspci.c

index e0c8bd045e1c31464fb4b836945b2b1904992c16..b61db0c91856b9d773c3695272e81223cded467e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Mar 19 17:03:48 1998  Martin Mares  <mj@lomikel.karlin.mff.cuni.cz>
+
+       * lspci.c (grow_tree, show_tree_dev, print_it): Fixed displaying
+       of PCI-to-PCI bridges in the tree format.
+
 Sun Feb 15 10:12:25 1998  Martin Mares  <mj@albireo.ucw.cz>
 
        * lspci.c (show_machine): Added non-verbose mode of machine-readable
diff --git a/lspci.c b/lspci.c
index ae061a3b63b3f568e742789e654ca93a48b6a974..19c66609c405c7d71d4776866a3329cff12883ed 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1,5 +1,5 @@
 /*
- *     $Id: lspci.c,v 1.8 1998/02/15 09:30:39 mj Exp $
+ *     $Id: lspci.c,v 1.9 1998/03/19 15:56:43 mj Exp $
  *
  *     Linux PCI Utilities -- List All PCI Devices
  *
@@ -715,11 +715,11 @@ static void
 grow_tree(void)
 {
   struct device *d, *d2;
-  struct bridge *first_br, *b;
+  struct bridge **last_br, *b;
 
   /* Build list of bridges */
 
-  first_br = &host_bridge;
+  last_br = &host_bridge.chain;
   for(d=first_dev; d; d=d->next)
     {
       word class = get_conf_word(d, PCI_CLASS_DEVICE);
@@ -729,21 +729,22 @@ grow_tree(void)
          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);
-         b->chain = first_br;
-         first_br = b;
+         *last_br = b;
+         last_br = &b->chain;
          b->next = b->child = NULL;
          b->first_bus = NULL;
          b->br_dev = d;
        }
     }
+  *last_br = NULL;
 
   /* Create a bridge tree */
 
-  for(b=first_br; b; b=b->chain)
+  for(b=&host_bridge; b; b=b->chain)
     {
       struct bridge *c, *best;
       best = NULL;
-      for(c=first_br; c; c=c->chain)
+      for(c=&host_bridge; c; c=c->chain)
        if (c != b && b->primary >= c->secondary && b->primary <= c->subordinate &&
            (!best || best->subordinate - best->primary > c->subordinate - c->primary))
          best = c;
@@ -756,7 +757,7 @@ grow_tree(void)
 
   /* Insert secondary bus for each bridge */
 
-  for(b=first_br; b; b=b->chain)
+  for(b=&host_bridge; b; b=b->chain)
     if (!find_bus(b, b->secondary))
       new_bus(b, b->secondary);
 
@@ -777,7 +778,7 @@ print_it(byte *line, byte *p)
   *p = 0;
   fputs(line, stdout);
   for(p=line; *p; p++)
-    if (*p == '+')
+    if (*p == '+' || *p == '|')
       *p = '|';
     else
       *p = ' ';
@@ -794,7 +795,10 @@ show_tree_dev(struct device *d, byte *line, byte *p)
   for(b=&host_bridge; b; b=b->chain)
     if (b->br_dev == d)
       {
-       p += sprintf(p, "-[%02x-%02x]-", b->secondary, b->subordinate);
+       if (b->secondary == b->subordinate)
+         p += sprintf(p, "-[%02x]-", b->secondary);
+       else
+         p += sprintf(p, "-[%02x-%02x]-", b->secondary, b->subordinate);
         show_tree_bridge(b, line, p);
         return;
       }