]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Library: The list of capabilities is ordered properly
authorMartin Mares <mj@ucw.cz>
Mon, 31 Dec 2018 14:28:25 +0000 (15:28 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 31 Dec 2018 14:28:25 +0000 (15:28 +0100)
Ordering of our cached list of capabilities now respects the original
order in the device's configuration space.

lib/caps.c
lib/pci.h

index 00b9653fa75253757cfc7e44de4dd38766e2b03e..6574a10adb9e205e35f1fb2edc25567153b84761 100644 (file)
@@ -15,8 +15,11 @@ pci_add_cap(struct pci_dev *d, unsigned int addr, unsigned int id, unsigned int
 {
   struct pci_cap *cap = pci_malloc(d->access, sizeof(*cap));
 
-  cap->next = d->first_cap;
-  d->first_cap = cap;
+  if (d->last_cap)
+    d->last_cap->next = cap;
+  else
+    d->first_cap = cap;
+  d->last_cap = cap;
   cap->addr = addr;
   cap->id = id;
   cap->type = type;
index a08f5ec7ab0718b60a4c657c4a87d8920efeb52c..abee05a5b656ef5d245f0b03cf7dafbb914d6720 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -150,6 +150,7 @@ struct pci_dev {
   int hdrtype;                         /* Cached low 7 bits of header type, -1 if unknown */
   void *aux;                           /* Auxiliary data */
   struct pci_property *properties;     /* A linked list of extra properties */
+  struct pci_cap *last_cap;            /* Last capability in the list */
 };
 
 #define PCI_ADDR_IO_MASK (~(pciaddr_t) 0x3)