while (ttl-- && pos >= 0x40) { pos &= ~3; pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, &id); if (id == 0xff) break; if (id == cap) return pos; pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_NEXT, &pos); } return 0;
return __pci_find_next_cap(bus, devfn, pos, cap);
static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_type, int cap){	u16 status;	u8 pos, id;	int ttl = 48;	pci_bus_read_config_word(bus, devfn, PCI_STATUS, &status);	if (!(status & PCI_STATUS_CAP_LIST))		return 0;	switch (hdr_type) {	case PCI_HEADER_TYPE_NORMAL:	case PCI_HEADER_TYPE_BRIDGE:		pci_bus_read_config_byte(bus, devfn, PCI_CAPABILITY_LIST, &pos);		break;	case PCI_HEADER_TYPE_CARDBUS:		pci_bus_read_config_byte(bus, devfn, PCI_CB_CAPABILITY_LIST, &pos);		break;	default:		return 0;	}	while (ttl-- && pos >= 0x40) {		pos &= ~3;		pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, &id);		if (id == 0xff)			break;		if (id == cap)			return pos;		pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_NEXT, &pos);	}	return 0;}