From: Heiko Schocher Date: Mon, 27 Apr 2015 07:42:07 +0200 Subject: [U-Boot] [PATCH v6 4/4] mtd, spi: check if flash pointer is used In-Reply-To: <1430113328-29184-1-git-send-email-hs@denx.de> References: <1430113328-29184-1-git-send-email-hs@denx.de> Message-ID: <1430113328-29184-5-git-send-email-hs@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de if flash pointer is used free it, before probing a new flash and storing it in flash. Signed-off-by: Heiko Schocher --- Changes in v6: - add comments from Jagan Teki: new patch in this patchserie, extract this piece of code into a new patch. Changes in v2: None common/cmd_sf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 3bf9119..e58058d 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; -- 2.1.0