[PATCH 05/11] PCI: Move pci_read_bases() wrapper with BUILD_BUG_ON() to pci.h
From: Ilpo Järvinen
Date: Mon Nov 09 2026 - 16:10:08 EST
pci_read_bases() is static in probe.c. An upcoming change moves CardBus
device setup into setup-cardbus.c, which needs to read the CardBus
BAR from outside probe.c.
Move the body of pci_read_bases() into __pci_read_bases() and keep the
BUILD_BUG_ON() check in an __always_inline pci_read_bases() wrapper in
pci.h so all callers retain the check.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
---
drivers/pci/pci.h | 10 ++++++++++
drivers/pci/probe.c | 5 +----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 519918e24cc5..798b31c31ae4 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -532,6 +532,16 @@ void __pci_size_stdbars(struct pci_dev *dev, int count,
unsigned int pos, u32 *sizes);
int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
struct resource *res, unsigned int reg, u32 *sizes);
+void __pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom);
+
+static __always_inline void pci_read_bases(struct pci_dev *dev,
+ unsigned int howmany, int rom)
+{
+ BUILD_BUG_ON(statically_true(howmany > PCI_STD_NUM_BARS));
+
+ __pci_read_bases(dev, howmany, rom);
+}
+
void pci_configure_ari(struct pci_dev *dev);
int pci_dev_res_add_to_list(struct list_head *head, struct pci_dev *dev,
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1c2caf3ce664..a20ceaf7307a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -322,15 +322,12 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;
}
-static __always_inline void pci_read_bases(struct pci_dev *dev,
- unsigned int howmany, int rom)
+void __pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
{
u32 rombar, stdbars[PCI_STD_NUM_BARS];
unsigned int pos, reg;
u16 orig_cmd;
- BUILD_BUG_ON(statically_true(howmany > PCI_STD_NUM_BARS));
-
if (dev->non_compliant_bars)
return;
--
2.47.3