Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55db3208 authored by Sean O. Stalley's avatar Sean O. Stalley Committed by Bjorn Helgaas
Browse files

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: default avatarSean O. Stalley <sean.stalley@intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 387d3757
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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;

	while ((*ttl)--) {
	pci_bus_read_config_byte(bus, devfn, pos, &pos);

	while ((*ttl)--) {
		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;
}