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 <b...@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