aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-12-27 12:31:55 +0100
committerMartin Mares <mj@ucw.cz>2022-02-10 13:49:35 +0100
commit2dc7b53bc955ac51a56706fc305779ef0cf78dcd (patch)
treee6b1e6beb265145acfa96bdca0b8f5b05083d371
parentb84f21545827cca1150bb53906257f80ebb5a84e (diff)
downloadpciutils-2dc7b53bc955ac51a56706fc305779ef0cf78dcd.tar.gz
libpci: generic: Implement CLASS_EXT and SUBSYS support
PCI_FILL_SUBSYS is implemented only for PCI_HEADER_TYPE_NORMAL and PCI_HEADER_TYPE_CARDBUS like in lspci.
-rw-r--r--lib/generic.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/generic.c b/lib/generic.c
index e80158f..1c1f8a3 100644
--- a/lib/generic.c
+++ b/lib/generic.c
@@ -96,6 +96,29 @@ pci_generic_fill_info(struct pci_dev *d, unsigned int flags)
if (want_fill(d, flags, PCI_FILL_CLASS))
d->device_class = pci_read_word(d, PCI_CLASS_DEVICE);
+ if (want_fill(d, flags, PCI_FILL_CLASS_EXT))
+ {
+ d->prog_if = pci_read_byte(d, PCI_CLASS_PROG);
+ d->rev_id = pci_read_byte(d, PCI_REVISION_ID);
+ }
+
+ if (want_fill(d, flags, PCI_FILL_SUBSYS))
+ {
+ switch (get_hdr_type(d))
+ {
+ case PCI_HEADER_TYPE_NORMAL:
+ d->subsys_vendor_id = pci_read_word(d, PCI_SUBSYSTEM_VENDOR_ID);
+ d->subsys_id = pci_read_word(d, PCI_SUBSYSTEM_ID);
+ break;
+ case PCI_HEADER_TYPE_CARDBUS:
+ d->subsys_vendor_id = pci_read_word(d, PCI_CB_SUBSYSTEM_VENDOR_ID);
+ d->subsys_id = pci_read_word(d, PCI_CB_SUBSYSTEM_ID);
+ break;
+ default:
+ clear_fill(d, PCI_FILL_SUBSYS);
+ }
+ }
+
if (want_fill(d, flags, PCI_FILL_IRQ))
d->irq = pci_read_byte(d, PCI_INTERRUPT_LINE);