Attention is currently required from: Francois Toguo Fotso, Tim Wawrzynczak, Karthik Ramasubramanian. Subrata Banik has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/57784 )
Change subject: device: Add pciexp_find_next_extended_cap function ......................................................................
Patch Set 2:
(1 comment)
File src/device/pciexp_device.c:
https://review.coreboot.org/c/coreboot/+/57784/comment/490cf020_8872b9a1 PS2, Line 2: @Tim, Can you please check below code refactoring if it helps
static unsigned int pciexp_get_ext_cap_offset(struct device *dev, unsigned int cap, unsigned int offset) { unsigned int this_cap_offset = offset; unsigned int next_cap_offset, this_cap, cafe;
do { this_cap = pci_read_config32(dev, this_cap_offset); cafe = pci_read_config32(dev, this_cap_offset + 4);
if (this_cap & 0xffff == cap) return this_cap_offset; else if (cafe & 0xffff == cap) return this_cap_offset + 4; else { next_cap_offset = this_cap >> 20; this_cap_offset = next_cap_offset; } } while (next_cap_offset != 0);
return 0; }
unsigned int pciexp_find_next_extended_cap(struct device *dev, unsigned int cap, unsigned int pos) { unsigned int next_cap_offset = pci_read_config32(dev, pos) >> 20;
return pciexp_get_ext_cap_offset(dev, cap, next_cap_offset); }
unsigned int pciexp_find_extended_cap(struct device *dev, unsigned int cap) { return pciexp_get_ext_cap_offset(dev, cap, PCIE_EXT_CAP_OFFSET); }