cmd: sf Drop reassignment of new into flash
authorJagan Teki <jagan@amarulasolutions.com>
Wed, 13 May 2020 10:58:01 +0000 (16:28 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Mon, 1 Jun 2020 12:25:24 +0000 (17:55 +0530)
The new pointer points to flash found and that would
assign it to global 'flash' pointer for further flash
operations and also keep track of old flash pointer.

This would happen if the probe is successful or even
failed, but current code assigning new into flash before
and after checking the new.

So, drop the assignment after new checks so flash always
latest new pointer even if probe failed or succeed.

Cc: Simon Glass <sjg@chromium.org>
Cc: Vignesh R <vigneshr@ti.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
cmd/sf.c

index 727837d9cd1f7c99d1cb5ed7fbc90d7ca2bdc8fd..d18f6a888ce48c6ec142e7c658a828668d3c079e 100644 (file)
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -145,13 +145,10 @@ static int do_spi_flash_probe(int argc, char *const argv[])
 
        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;
        }
-
-       flash = new;
 #endif
 
        return 0;