diff mbox series

[2/5] cmd: sf Drop reassignment of new into flash

Message ID 20200514121145.28737-3-jagan@amarulasolutions.com
State Accepted
Commit da37b539e62604d090fbc5b52246f8e810f2f9a7
Headers show
Series sf: Cleanup | expand

Commit Message

Jagan Teki May 14, 2020, 12:11 p.m. UTC
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 at chromium.org>
Cc: Vignesh R <vigneshr at ti.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 cmd/sf.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Jagan Teki May 19, 2020, 7:25 p.m. UTC | #1
On Thu, May 14, 2020 at 5:42 PM Jagan Teki <jagan at amarulasolutions.com> wrote:
>
> 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 at chromium.org>
> Cc: Vignesh R <vigneshr at ti.com>
> Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
> ---

Applied to u-boot-spi/master
diff mbox series

Patch

diff --git a/cmd/sf.c b/cmd/sf.c
index e993b3e5ad..302201c2b0 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -141,13 +141,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;