Commit 8ee81b7f9b675cb675119a998b04ca843d24ddcd
Committed by
Jagan Teki
1 parent
2ec1a4059c
Exists in
v2017.01-smarct4x
and in
34 other branches
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>
Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff
common/cmd_sf.c
... | ... | @@ -135,7 +135,12 @@ |
135 | 135 | |
136 | 136 | flash = dev_get_uclass_priv(new); |
137 | 137 | #else |
138 | + if (flash) | |
139 | + spi_flash_free(flash); | |
140 | + | |
138 | 141 | new = spi_flash_probe(bus, cs, speed, mode); |
142 | + flash = new; | |
143 | + | |
139 | 144 | if (!new) { |
140 | 145 | printf("Failed to initialize SPI flash at %u:%u\n", bus, cs); |
141 | 146 | return 1; |