summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2018-12-31 15:28:25 +0100
committerMartin Mares <mj@ucw.cz>2018-12-31 15:28:25 +0100
commit9c48ed23cd16066e662b45f5ff1776b0b8a1bd4c (patch)
treef4f592ee6417e52236fb2d97f669f5244105d3ee
parent10168b8444c1cf42884c637916d47cf59c05676a (diff)
downloadpciutils-9c48ed23cd16066e662b45f5ff1776b0b8a1bd4c.tar.gz
Library: The list of capabilities is ordered properly
Ordering of our cached list of capabilities now respects the original order in the device's configuration space.
-rw-r--r--lib/caps.c7
-rw-r--r--lib/pci.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/caps.c b/lib/caps.c
index 00b9653..6574a10 100644
--- a/lib/caps.c
+++ b/lib/caps.c
@@ -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;
diff --git a/lib/pci.h b/lib/pci.h
index a08f5ec..abee05a 100644
--- 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)