]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
lspci: Allow -s with -t to show a subtree
authorGera Kazakov <gera.kazakov@liqid.com>
Tue, 18 Sep 2018 23:51:07 +0000 (17:51 -0600)
committerMartin Mares <mj@ucw.cz>
Sun, 14 Oct 2018 20:59:40 +0000 (22:59 +0200)
ls-tree.c
lspci.c
lspci.h

index 8d60ea2b417c96c1e534c53193b1e78dccd12734..6995dd220a313bc33eab07b03072ba5ae0f5d352 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -234,8 +234,23 @@ show_tree_bridge(struct bridge *b, char *line, char *p)
 }
 
 void
-show_forest(void)
+show_forest(struct pci_filter *filter)
 {
   char line[256];
-  show_tree_bridge(&host_bridge, line, line);
+  if (filter == NULL)
+    show_tree_bridge(&host_bridge, line, line);
+  else
+    {
+      struct bridge *b;
+      for (b=&host_bridge; b; b=b->chain)
+        {
+          if (b->br_dev && pci_filter_match(filter, b->br_dev->dev))
+            {
+                struct pci_dev *d = b->br_dev->dev;
+                char *p = line;
+                p += sprintf(line, "%04x:%02x:", d->domain_16, d->bus);
+                show_tree_dev(b->br_dev, line, p);
+            }
+        }
+    }
 }
diff --git a/lspci.c b/lspci.c
index 3dabbdeda711560049ccd677c6e59998c4e379ba..d63b6d0a447aa6886f9eb79d563efcfa480b329b 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1077,9 +1077,6 @@ main(int argc, char **argv)
   if (optind < argc)
     goto bad;
 
-  if (opt_tree && opt_filter)
-    die("Tree mode does not support filtering");
-
   if (opt_query_dns)
     {
       pacc->id_lookup_mode |= PCI_LOOKUP_NETWORK;
@@ -1103,7 +1100,7 @@ main(int argc, char **argv)
       if (need_topology)
        grow_tree();
       if (opt_tree)
-       show_forest();
+       show_forest(opt_filter ? &filter : NULL);
       else
        show();
     }
diff --git a/lspci.h b/lspci.h
index 9c12eb8e85c25d17f4407a5225709ab1a1449d78..fefee5256423a4790487e06cd31419eb8d5d978a 100644 (file)
--- a/lspci.h
+++ b/lspci.h
@@ -107,7 +107,7 @@ struct bus {
 extern struct bridge host_bridge;
 
 void grow_tree(void);
-void show_forest(void);
+void show_forest(struct pci_filter *filter);
 
 /* ls-map.c */