From: Bryan O'Donoghue Date: Sun, 22 Dec 2019 18:05:19 +0000 Subject: [PATCH] env: sf: Don't call spi_flash_free when CONFIG_DM_SPI_FLASH=y Message-ID: <20191222180519.1595549-1-bod@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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