From cab89f7d111344ebd9a4e3e379131c071e41b397 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 2 Apr 2025 16:05:23 +0000 Subject: [PATCH] commonlib/storage: Avoid build error when CONFIG_PCI is disabled When CONFIG_PCI is disabled, but COMMONLIB_STORAGE and COMMONLIB_STORAGE_SD are enabled, the compilation of pci_sdhci.c fails. This is because the code attempts to use pci_s_read_config32() with the PCI_BASE_ADDRESS_0 macro, which are only defined when CONFIG_PCI is enabled. Add an early return NULL check based on !CONFIG(PCI) at the beginning of new_pci_sdhci_controller(). This prevents the compiler from attempting to process the PCI-specific code path when PCI support is not configured, resolving the build failure in this specific Kconfig scenario. TEST=Able to build herobrine. Change-Id: I5c70d9b9ebcac13b47bba2c260fdf2ad7d56d4d7 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/87092 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/commonlib/storage/pci_sdhci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commonlib/storage/pci_sdhci.c b/src/commonlib/storage/pci_sdhci.c index f7922d42ea..51b44deabb 100644 --- a/src/commonlib/storage/pci_sdhci.c +++ b/src/commonlib/storage/pci_sdhci.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -42,6 +43,9 @@ struct sd_mmc_ctrlr *new_pci_sdhci_controller(pci_devfn_t dev) { uintptr_t addr; + if (!CONFIG(PCI)) + return NULL; + addr = pci_s_read_config32(dev, PCI_BASE_ADDRESS_0); if (addr == ((uint32_t)~0)) { sdhc_error("Error: PCI SDHCI not found\n");