From 888ddf0e53f304d61326665bca3294f38129d7c9 Mon Sep 17 00:00:00 2001 From: Gera Kazakov Date: Tue, 18 Sep 2018 17:51:07 -0600 Subject: [PATCH] lspci: Allow -s with -t to show a subtree --- ls-tree.c | 19 +++++++++++++++++-- lspci.c | 5 +---- lspci.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ls-tree.c b/ls-tree.c index 8d60ea2..6995dd2 100644 --- 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 3dabbde..d63b6d0 100644 --- 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 9c12eb8..fefee52 100644 --- 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 */ -- 2.39.2