]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
libpci: generic: Implement CLASS_EXT and SUBSYS support
authorPali Rohár <pali@kernel.org>
Mon, 27 Dec 2021 11:31:55 +0000 (12:31 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 10 Feb 2022 12:49:35 +0000 (13:49 +0100)
PCI_FILL_SUBSYS is implemented only for PCI_HEADER_TYPE_NORMAL and
PCI_HEADER_TYPE_CARDBUS like in lspci.

lib/generic.c

index e80158fb9b14c82768b60d9018a0d6a9d4f1a9ed..1c1f8a3ff1a81b305b0102d4e32b7c6455104804 100644 (file)
@@ -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);