diff options
author | Martin Mares <mj@ucw.cz> | 2018-12-31 15:28:25 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2018-12-31 15:28:25 +0100 |
commit | 9c48ed23cd16066e662b45f5ff1776b0b8a1bd4c (patch) | |
tree | f4f592ee6417e52236fb2d97f669f5244105d3ee | |
parent | 10168b8444c1cf42884c637916d47cf59c05676a (diff) | |
download | pciutils-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.c | 7 | ||||
-rw-r--r-- | lib/pci.h | 1 |
2 files changed, 6 insertions, 2 deletions
@@ -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; @@ -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) |