From: Heiko Schocher Date: Mon, 27 Apr 2015 05:42:07 +0000 (+0200) Subject: mtd, spi: Check if flash pointer is used X-Git-Tag: v2015.07-rc3~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8ee81b7f9b675cb675119a998b04ca843d24ddcd;p=oweals%2Fu-boot.git mtd, spi: Check if flash pointer is used If flash pointer is used free it, before probing a new flash and storing it in flash. Signed-off-by: Heiko Schocher Tested-by: Jagannadh Teki Reviewed-by: Jagannadh Teki --- diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 9bced29cf9..aef8c2a5ea 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -135,7 +135,12 @@ static int do_spi_flash_probe(int argc, char * const argv[]) flash = dev_get_uclass_priv(new); #else + if (flash) + spi_flash_free(flash); + new = spi_flash_probe(bus, cs, speed, mode); + flash = new; + if (!new) { printf("Failed to initialize SPI flash at %u:%u\n", bus, cs); return 1;