]> mj.ucw.cz Git - pciutils.git/commitdiff
Device labels must be requested via PCI_FILL_LABELS
authorMartin Mares <mj@ucw.cz>
Sat, 1 Nov 2014 16:11:17 +0000 (17:11 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 1 Nov 2014 16:11:17 +0000 (17:11 +0100)
The previous implementation handled labels differently from all
other device properties, which was illogical.

lib/pci.h
lib/sysfs.c
lspci.c

index 0670b18167ffdaf331a7d91d6a07c01ac5a4f829..37f08e62d40058f1d6752978edcf9c323a941ab1 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -169,6 +169,7 @@ int pci_fill_info(struct pci_dev *, int flags) PCI_ABI; /* Fill in device inform
 #define PCI_FILL_EXT_CAPS      128
 #define PCI_FILL_PHYS_SLOT     256
 #define PCI_FILL_MODULE_ALIAS  512
+#define PCI_FILL_LABEL         1024
 #define PCI_FILL_RESCAN                0x10000
 
 void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI;
index 01b5eaeca5963ef68b25ec257d06861b5c8790d6..9f348bbc34a6b98c99704dd52a1092cbb5ad38a7 100644 (file)
@@ -161,7 +161,7 @@ sysfs_get_resources(struct pci_dev *d)
 
 static void sysfs_scan(struct pci_access *a)
 {
-  char dirname[1024], buf[OBJBUFSIZE];
+  char dirname[1024];
   DIR *dir;
   struct dirent *entry;
   int n;
@@ -199,9 +199,6 @@ 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;
-         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);
@@ -287,6 +284,13 @@ sysfs_fill_info(struct pci_dev *d, int flags)
        d->module_alias = pci_strdup(d->access, buf);
     }
 
+  if ((flags & PCI_FILL_LABEL) && !(d->known_fields & PCI_FILL_LABEL))
+    {
+      char buf[OBJBUFSIZE];
+      if (sysfs_get_string(d, "label", buf, 0))
+       d->label = pci_strdup(d->access, buf);
+    }
+
   return pci_generic_fill_info(d, flags);
 }
 
diff --git a/lspci.c b/lspci.c
index 39a464772f8e8649e19d2e8438ffd85d7f94887d..da0aac7e2aa4c4517e60928854f7a1300d69fb13 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -138,7 +138,7 @@ scan_device(struct pci_dev *p)
        d->config_cached += 64;
     }
   pci_setup_cache(p, d->config, d->config_cached);
-  pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | PCI_FILL_PHYS_SLOT);
+  pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | PCI_FILL_PHYS_SLOT | PCI_FILL_LABEL);
   return d;
 }