diff options
author | Pali Rohár <pali@kernel.org> | 2021-12-27 14:05:32 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2022-02-10 13:49:35 +0100 |
commit | 1579c198ae9ddbb92a9ebc29f76eec169397fdd4 (patch) | |
tree | 242d055449402059e07499132223b3fdd3f4c092 | |
parent | 2b883e3fd5ad2da5351599f327cc76006e2ef2f0 (diff) | |
download | pciutils-1579c198ae9ddbb92a9ebc29f76eec169397fdd4.tar.gz |
libpci: proc: Implement support for PCI_FILL_DRIVER
File /proc/bus/pci/devices contains optional driver name in the last 18th field.
-rw-r--r-- | lib/proc.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -11,6 +11,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <ctype.h> #include <errno.h> #include <fcntl.h> #include <sys/types.h> @@ -69,9 +70,11 @@ proc_scan(struct pci_access *a) { struct pci_dev *d = pci_alloc_dev(a); unsigned int dfn, vend, cnt, known; + char *driver; + int offset; #define F " " PCIADDR_T_FMT - cnt = sscanf(buf, "%x %x %x" F F F F F F F F F F F F F F, + cnt = sscanf(buf, "%x %x %x" F F F F F F F F F F F F F F "%n", &dfn, &vend, &d->irq, @@ -88,7 +91,8 @@ proc_scan(struct pci_access *a) &d->size[3], &d->size[4], &d->size[5], - &d->rom_size); + &d->rom_size, + &offset); #undef F if (cnt != 9 && cnt != 10 && cnt != 17) a->error("proc: parse error (read only %d items)", cnt); @@ -106,6 +110,20 @@ proc_scan(struct pci_access *a) if (cnt >= 17) known |= PCI_FILL_SIZES; } + if (cnt >= 17) + { + while (buf[offset] && isspace(buf[offset])) + ++offset; + driver = &buf[offset]; + while (buf[offset] && !isspace(buf[offset])) + ++offset; + buf[offset] = '\0'; + if (driver[0]) + { + pci_set_property(d, PCI_FILL_DRIVER, driver); + known |= PCI_FILL_DRIVER; + } + } d->known_fields = known; pci_link_dev(a, d); } |