diff options
author | Sean O. Stalley <sean.stalley@intel.com> | 2015-04-02 21:10:19 (GMT) |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2015-04-09 22:01:39 (GMT) |
commit | 55db3208f238ee776f1f747734051723d8a3c13e (patch) | |
tree | ee168a99ac30c859d8158de29be3b25e4ab8078f | |
parent | 387d37577fdd05e9472c20885464c2a53b3c945f (diff) | |
download | linux-55db3208f238ee776f1f747734051723d8a3c13e.tar.xz |
PCI: Read capability list as dwords, not bytes
Reading both the capability ID and "next" pointer at the same time lets us
parse the list with half the number of config reads.
Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | drivers/pci/pci.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 81f06e8..3c84cc6 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -145,19 +145,22 @@ static int __pci_find_next_cap_ttl(struct pci_bus *bus, unsigned int devfn, u8 pos, int cap, int *ttl) { u8 id; + u16 ent; + + pci_bus_read_config_byte(bus, devfn, pos, &pos); while ((*ttl)--) { - pci_bus_read_config_byte(bus, devfn, pos, &pos); if (pos < 0x40) break; pos &= ~3; - pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, - &id); + pci_bus_read_config_word(bus, devfn, pos, &ent); + + id = ent & 0xff; if (id == 0xff) break; if (id == cap) return pos; - pos += PCI_CAP_LIST_NEXT; + pos = (ent >> 8); } return 0; } |