]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
authorThomas Renninger <trenn@suse.de>
Tue, 28 Jan 2014 07:51:02 +0000 (08:51 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 1 Nov 2014 15:20:48 +0000 (16:20 +0100)
The Device name of a PCI or PCI Express device under OS may be exported via
ACPI _DSM function with function index 7.
This allows to connect a described PCI device in the platform documentation
or as labeled on the chassis with PCI devices shown via lspci.
The kernel already exports this string through sysfs under a PCI device through
the "label" sysfs attribute.

This patch reads the device name if available and shows it to the user.
Real world examples:
  Device Name: "USB HS EHCI Controller #2 #3"
  Device Name: "USB HS EHCI Controller #1"
  Device Name: "SATA Controller #1"
  Device Name: "Onboard LAN #1"
  Device Name: "Onboard LAN #2"
  Device Name: "Onboard Video (PILOT-3)"

Compare with PCI Firmware Spec v3.1 chapter 4.6.7 and
ACPI spec v5.0 chapter 9.14.1

The DeviceName is not shown by default, but starting from first verbose
parameter (-v).

V2: - Free label string if allocated
    - Enhance changelog

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: linux-pci@vger.kernel.org
lib/access.c
lib/pci.h
lib/sysfs.c
lspci.c

index 5112504173f6814b371b66c1236308212e8010c5..c23a2fd159723f62f9febcdb2f6bea26db600672 100644 (file)
@@ -60,6 +60,7 @@ void pci_free_dev(struct pci_dev *d)
     d->methods->cleanup_dev(d);
   pci_free_caps(d);
   pci_mfree(d->module_alias);
+  pci_mfree(d->label);
   pci_mfree(d->phy_slot);
   pci_mfree(d);
 }
index 38e2e9911d228f3e21ba82924f36591a3ae25606..f31419d2a0a045c9fee7f26cf76d4ed98c228495 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -131,6 +131,7 @@ struct pci_dev {
   struct pci_cap *first_cap;           /* List of capabilities */
   char *phy_slot;                      /* Physical slot */
   char *module_alias;                  /* Linux kernel module alias */
+  char *label;                         /* Device name as exported by BIOS */
 
   /* Fields used internally: */
   struct pci_access *access;
index 5a48c0db86285ea226a836a6fd185514c227d77d..3a8a34f36b451f8ad4088b16e858e5cff94b6835 100644 (file)
@@ -199,6 +199,10 @@ static void sysfs_scan(struct pci_access *a)
          d->vendor_id = sysfs_get_value(d, "vendor");
          d->device_id = sysfs_get_value(d, "device");
          d->device_class = sysfs_get_value(d, "class") >> 8;
+         char buf[1024];
+         if (sysfs_get_string(d, "label", buf, 0))
+           d->label = pci_strdup(d->access, buf);
+
          d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
        }
       pci_link_dev(a, d);
diff --git a/lspci.c b/lspci.c
index dbba6782401eb8598b023088e54c3a2c529b42e6..eb17af5a2ab5828d7a18d06478781ef1ac83d37d 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -315,6 +315,8 @@ show_terse(struct device *d)
       word subsys_v, subsys_d;
       char ssnamebuf[256];
 
+      if (p->label)
+        printf("\tDeviceName: %s", p->label);
       get_subid(d, &subsys_v, &subsys_d);
       if (subsys_v && subsys_v != 0xffff)
        printf("\tSubsystem: %s\n",