[PATCH] env: sf: Don't call spi_flash_free when CONFIG_DM_SPI_FLASH=y

Bryan O'Donoghue bod at denx.de
Sun Dec 22 19:05:19 CET 2019


As cmd/sf.c shows we don't want to call spi_free_flash() if
CONFIG_DM_SPI_FLASH is true.

This fixes a bug where ENV_IN_SPI_FLASH is true and partitions are
allocated on a DM_SPI_FLASH. The environment will load from SPI flash and
the dm device will appear in "dm tree" but, no MTD devices will be found
because spi_free_flash() will have removed the MTD device from mtd_idr.

Fix this case by avoiding the spi_free_flash() call when DM_SPI_FLASH is
true as we already do in cmd/sf.c.

Signed-off-by: Bryan O'Donoghue <bod at denx.de>
---
 env/sf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/env/sf.c b/env/sf.c
index 5ef4055219..2563a1fbe4 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -178,7 +178,9 @@ static int env_sf_load(void)
 	ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
 				read2_fail);
 
+#ifndef CONFIG_DM_SPI_FLASH
 	spi_flash_free(env_flash);
+#endif
 	env_flash = NULL;
 out:
 	free(tmp_env1);
-- 
2.24.0



More information about the U-Boot mailing list