summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2018-08-12 11:24:06 +0200
committerMartin Mares <mj@ucw.cz>2018-08-12 11:24:06 +0200
commit743537025ebcae2a919317fd22daaa4a23e6bb25 (patch)
tree890c01ea05fc43105a966dd28f4ad363f1941995
parentad0e2fc2b25874c0e92ebecab9038f413d73e263 (diff)
downloadpciutils-topology.tar.gz
Topology now works in combination with filterstopology
If bus topology is needed, we scan all devices regardless of filters, and apply the filters later when showing devices. Also, we forbid several impossible combinations of options: tree mode with filters, bus mapping mode with anything requiring topology.
-rw-r--r--ls-tree.c2
-rw-r--r--lspci.c22
2 files changed, 16 insertions, 8 deletions
diff --git a/ls-tree.c b/ls-tree.c
index 8ce9b4f..8d60ea2 100644
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -237,7 +237,5 @@ void
show_forest(void)
{
char line[256];
-
- grow_tree();
show_tree_bridge(&host_bridge, line, line);
}
diff --git a/lspci.c b/lspci.c
index 391f1b2..75cb5b9 100644
--- a/lspci.c
+++ b/lspci.c
@@ -18,6 +18,7 @@
int verbose; /* Show detailed information */
static int opt_hex; /* Show contents of config space as hexadecimal numbers */
struct pci_filter filter; /* Device filter */
+static int opt_filter; /* Any filter was given */
static int opt_tree; /* Show bus tree */
static int opt_path; /* Show bridge path */
static int opt_machine; /* Generate machine-readable output */
@@ -80,6 +81,7 @@ GENERIC_HELP
struct pci_access *pacc;
struct device *first_dev;
static int seen_errors;
+static int need_topology;
int
config_fetch(struct device *d, unsigned int pos, unsigned int len)
@@ -116,7 +118,7 @@ scan_device(struct pci_dev *p)
if (p->domain && !opt_domains)
opt_domains = 1;
- if (!pci_filter_match(&filter, p))
+ if (!pci_filter_match(&filter, p) && !need_topology)
return NULL;
d = xmalloc(sizeof(struct device));
memset(d, 0, sizeof(*d));
@@ -973,10 +975,9 @@ show(void)
{
struct device *d;
- if (opt_path)
- grow_tree();
for (d=first_dev; d; d=d->next)
- show_device(d);
+ if (pci_filter_match(&filter, d->dev))
+ show_device(d);
}
/* Main */
@@ -1012,19 +1013,23 @@ main(int argc, char **argv)
case 's':
if (msg = pci_filter_parse_slot(&filter, optarg))
die("-s: %s", msg);
+ opt_filter = 1;
break;
case 'd':
if (msg = pci_filter_parse_id(&filter, optarg))
die("-d: %s", msg);
+ opt_filter = 1;
break;
case 'x':
opt_hex++;
break;
case 'P':
opt_path++;
+ need_topology = 1;
break;
case 't':
opt_tree++;
+ need_topology = 1;
break;
case 'i':
pci_set_name_list_path(pacc, optarg, 0);
@@ -1068,6 +1073,9 @@ 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;
@@ -1080,14 +1088,16 @@ main(int argc, char **argv)
pci_init(pacc);
if (opt_map_mode)
{
- if (opt_path)
- die("Bus paths cannot be shown in bus mapping mode");
+ if (need_topology)
+ die("Bus mapping mode does not recognize bus topology");
map_the_bus();
}
else
{
scan_devices();
sort_them();
+ if (need_topology)
+ grow_tree();
if (opt_tree)
show_forest();
else