From e84876c68e14e882551d3b7eaf60a0f0438c0f67 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 1 Nov 2014 17:11:17 +0100 Subject: [PATCH] Device labels must be requested via PCI_FILL_LABELS The previous implementation handled labels differently from all other device properties, which was illogical. --- lib/pci.h | 1 + lib/sysfs.c | 12 ++++++++---- lspci.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pci.h b/lib/pci.h index 0670b18..37f08e6 100644 --- 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; diff --git a/lib/sysfs.c b/lib/sysfs.c index 01b5eae..9f348bb 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -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 39a4647..da0aac7 100644 --- 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; } -- 2.39.2