summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2015-04-27 07:42:07 +0200
committerJagan Teki <jteki@openedev.com>2015-06-30 00:40:11 +0530
commit8ee81b7f9b675cb675119a998b04ca843d24ddcd (patch)
tree7b262b3a83c9d92354f24abdb87e9f26ee497f08
parent2ec1a4059cd0421653b19979a046e9fb7296652f (diff)
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 <hs@denx.de> Tested-by: Jagannadh Teki <jteki@openedev.com> Reviewed-by: Jagannadh Teki <jteki@openedev.com>
-rw-r--r--common/cmd_sf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 9bced29cf97..aef8c2a5ea8 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;