]> mj.ucw.cz Git - pciutils.git/commitdiff
Let `lspci -k' display subsystem names.
authorMartin Mares <mj@ucw.cz>
Sun, 9 Nov 2008 20:16:14 +0000 (21:16 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 9 Nov 2008 20:16:14 +0000 (21:16 +0100)
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

diff --git a/lspci.c b/lspci.c
index fcf4733d1a8faedb398a1b177885adbd7a578621..ddedb4243cf6d58da0470d7e4cb19da1b30b4bdd 100644 (file)
--- 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",