]> Gentwo Git Trees - linux/.git/commit
PCI: Refactor capability search into PCI_FIND_NEXT_CAP()
authorHans Zhang <18255117159@163.com>
Wed, 13 Aug 2025 14:45:25 +0000 (22:45 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 14 Aug 2025 20:03:40 +0000 (15:03 -0500)
commit3c02084d8fa521192ea19722b1e5efae8096d939
treeec90c776695c374992f828d95f8b6d42997c80ba
parent37d1ade89606875c9cd6eb3b4ee416b7e1800fc4
PCI: Refactor capability search into PCI_FIND_NEXT_CAP()

The PCI Capability search functionality is duplicated across the PCI core
and several controller drivers. The core's current implementation requires
fully initialized PCI device and bus structures, which prevents controller
drivers from using it during early initialization phases before these
structures are available.

Move the Capability search logic into a PCI_FIND_NEXT_CAP() macro that
accepts a config space accessor function as an argument. This enables
controller drivers to perform Capability discovery using their early
access mechanisms prior to full device initialization while sharing the
Capability search code.

Convert the existing PCI core Capability search implementation to use
PCI_FIND_NEXT_CAP().  Controller drivers can later use this with their
early access mechanisms while maintaining the existing protection against
infinite loops through preserved TTL checks.

Signed-off-by: Hans Zhang <18255117159@163.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Link: https://patch.msgid.link/20250813144529.303548-3-18255117159@163.com
drivers/pci/pci.c
drivers/pci/pci.h