From 15841b0a3441b84c0e20547ce893986822be96b2 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 9 Nov 2008 21:16:14 +0100 Subject: [PATCH] Let `lspci -k' display subsystem names. Several users have requested a `quick overview' mode that would display everything needed to identify a device and its drivers. I believe that it is better to extend the `-k' mode to include subsystems than to introduce yet another mode. --- lspci.c | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/lspci.c b/lspci.c index fcf4733..ddedb42 100644 --- a/lspci.c +++ b/lspci.c @@ -287,6 +287,25 @@ show_slot_name(struct device *d) printf("%02x:%02x.%d", p->bus, p->dev, p->func); } +static void +get_subid(struct device *d, word *subvp, word *subdp) +{ + byte htype = get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f; + + if (htype == PCI_HEADER_TYPE_NORMAL) + { + *subvp = get_conf_word(d, PCI_SUBSYSTEM_VENDOR_ID); + *subdp = get_conf_word(d, PCI_SUBSYSTEM_ID); + } + else if (htype == PCI_HEADER_TYPE_CARDBUS && d->config_cached >= 128) + { + *subvp = get_conf_word(d, PCI_CB_SUBSYSTEM_VENDOR_ID); + *subdp = get_conf_word(d, PCI_CB_SUBSYSTEM_ID); + } + else + *subvp = *subdp = 0xffff; +} + static void show_terse(struct device *d) { @@ -320,25 +339,19 @@ show_terse(struct device *d) } } putchar('\n'); -} -static void -get_subid(struct device *d, word *subvp, word *subdp) -{ - byte htype = get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f; - - if (htype == PCI_HEADER_TYPE_NORMAL) + if (verbose || opt_kernel) { - *subvp = get_conf_word(d, PCI_SUBSYSTEM_VENDOR_ID); - *subdp = get_conf_word(d, PCI_SUBSYSTEM_ID); + word subsys_v, subsys_d; + char ssnamebuf[256]; + + get_subid(d, &subsys_v, &subsys_d); + if (subsys_v && subsys_v != 0xffff) + printf("\tSubsystem: %s\n", + pci_lookup_name(pacc, ssnamebuf, sizeof(ssnamebuf), + PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, + p->vendor_id, p->device_id, subsys_v, subsys_d)); } - else if (htype == PCI_HEADER_TYPE_CARDBUS && d->config_cached >= 128) - { - *subvp = get_conf_word(d, PCI_CB_SUBSYSTEM_VENDOR_ID); - *subdp = get_conf_word(d, PCI_CB_SUBSYSTEM_ID); - } - else - *subvp = *subdp = 0xffff; } /*** Capabilities ***/ @@ -2311,8 +2324,6 @@ show_verbose(struct device *d) byte max_lat, min_gnt; byte int_pin = get_conf_byte(d, PCI_INTERRUPT_PIN); unsigned int irq = p->irq; - word subsys_v, subsys_d; - char ssnamebuf[256]; show_terse(d); @@ -2339,13 +2350,6 @@ show_verbose(struct device *d) return; } - get_subid(d, &subsys_v, &subsys_d); - if (subsys_v && subsys_v != 0xffff) - printf("\tSubsystem: %s\n", - pci_lookup_name(pacc, ssnamebuf, sizeof(ssnamebuf), - PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, - p->vendor_id, p->device_id, subsys_v, subsys_d)); - if (verbose > 1) { printf("\tControl: I/O%c Mem%c BusMaster%c SpecCycle%c MemWINV%c VGASnoop%c ParErr%c Stepping%c SERR%c FastB2B%c DisINTx%c\n", -- 2.39.5