diff mbox

[U-Boot,v7,4/4] mtd, spi: Check if flash pointer is used

Message ID 1435003217-21268-5-git-send-email-jteki@openedev.com
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagan Teki June 22, 2015, 8 p.m. UTC
From: Heiko Schocher <hs@denx.de>

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>
---
Changes in v7: none
Changes in v6:
- add comments from Jagan Teki:
  new patch in this patchserie, extract this piece
  of code into a new patch.

 common/cmd_sf.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 9bced29..aef8c2a 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;