From 2dc7b53bc955ac51a56706fc305779ef0cf78dcd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Mon, 27 Dec 2021 12:31:55 +0100 Subject: [PATCH] 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. --- lib/generic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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); -- 2.39.2