]> git.sur5r.net Git - u-boot/commitdiff
mtd, spi: Check if flash pointer is used
authorHeiko Schocher <hs@denx.de>
Mon, 27 Apr 2015 05:42:07 +0000 (07:42 +0200)
committerJagan Teki <jteki@openedev.com>
Mon, 29 Jun 2015 19:10:11 +0000 (00:40 +0530)
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>
common/cmd_sf.c

index 9bced29cf97a45dc6a8c78778b205eae69796a03..aef8c2a5ea8498073d520dfbc127c0c9acc32e19 100644 (file)
@@ -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;