[PATCH 16/26] spl: Don't cache devices when UNIT_TEST is enabled
Sean Anderson
seanga2 at gmail.com
Thu Oct 12 03:56:16 CEST 2023
Several SPL functions try to avoid performing initialization twice by
caching devices. This is fine for regular boot, but does not work with
UNIT_TEST, since all devices are torn down after each test. Disable caching
so we don't use stale devices.
Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---
common/spl/spl_fat.c | 2 +-
common/spl/spl_mmc.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index c6e2526ade1..8bec9cce5ca 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -24,7 +24,7 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
{
int err = 0;
- if (fat_registered)
+ if (!CONFIG_IS_ENABLED(UNIT_TEST) && fat_registered)
return err;
err = fat_register_device(block_dev, partition);
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 67c7ae34a58..a8579e29dee 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -417,7 +417,8 @@ int spl_mmc_load(struct spl_image_info *spl_image,
/* Perform peripheral init only once for an mmc device */
mmc_dev = spl_mmc_get_device_index(bootdev->boot_device);
- if (!mmc || spl_mmc_get_mmc_devnum(mmc) != mmc_dev) {
+ if (CONFIG_IS_ENABLED(UNIT_TEST) || !mmc ||
+ spl_mmc_get_mmc_devnum(mmc) != mmc_dev) {
err = spl_mmc_find_device(&mmc, bootdev->boot_device);
if (err)
return err;
--
2.37.1
More information about the U-Boot
mailing list