diff mbox series

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

Message ID 20191222180519.1595549-1-bod@denx.de
State Needs Review / ACK
Delegated to: Tom Rini
Headers show
Series env: sf: Don't call spi_flash_free when CONFIG_DM_SPI_FLASH=y | expand

Commit Message

Bryan O'Donoghue Dec. 22, 2019, 6:05 p.m. UTC
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@denx.de>
---
 env/sf.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

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);