From patchwork Sun Dec 22 18:05:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 1214764 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.b="ZX/v2yMB"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47gsg003pzz9sPV for ; Mon, 23 Dec 2019 06:16:59 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 00CA7814D5; Sun, 22 Dec 2019 20:16:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1577042204; bh=x1QwIy305mJ8XKF0sxzdQgGqIBWHidXN/C7PcQJNrX0=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=ZX/v2yMBunLvcwugmSwE2ZErcndAy3a3zjagVHSh1GQOYNAiN8A2tKKTuOUGFJpjh b3p36E7N254xHIwYVYFhLHhSxph8d33HiHI1IkJR+hXL8tgCGCIH4JeMJkY0PQ8k8J YWwLB2+1r8VRVSesq5H32us1sj9tELResUjqVWIkgYbPmN2mC2KM4RSaJ9DZV3MGby wz7nv0qQzUFmht0DYgPLhRfFeHwghuRRftiRSK+uBEDGxLVCyMDyx9Lrn2y7tLrq8f cG4SQDS4sD/qGDfNwINQeHFYwAk+dBfEG/kpBkgpWnnbes4CNuuaNqPYn0UYn29qdq dODsXEeQ8SV+Q== Received: by phobos.denx.de (Postfix, from userid 109) id A7ED181486; Sun, 22 Dec 2019 19:05:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=5.0 tests=SPF_HELO_NONE, SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63A5580615 for ; Sun, 22 Dec 2019 19:05:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=bod@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 47gr3v2n6bz1rQBt; Sun, 22 Dec 2019 19:04:59 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 47gr3v2N1zz1qqkv; Sun, 22 Dec 2019 19:04:59 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id n1NeA4FRDF0n; Sun, 22 Dec 2019 19:04:58 +0100 (CET) X-Auth-Info: SRG+afwXk/tIvPKd/hViFBjSbaOSgnncTuUTy31T/XA= Received: from localhost.localdomain (unknown [176.61.57.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 22 Dec 2019 19:04:58 +0100 (CET) From: Bryan O'Donoghue To: joe.hershberger@ni.com, wd@denx.de, u-boot@lists.denx.de Subject: [PATCH] env: sf: Don't call spi_flash_free when CONFIG_DM_SPI_FLASH=y Date: Sun, 22 Dec 2019 18:05:19 +0000 Message-Id: <20191222180519.1595549-1-bod@denx.de> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 22 Dec 2019 20:16:40 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bryan O'Donoghue Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean As cmd/sf.c shows we don't want to call spi_free_flash() if CONFIG_DM_SPI_FLASH is true. This fixes a bug where ENV_IN_SPI_FLASH is true and partitions are allocated on a DM_SPI_FLASH. The environment will load from SPI flash and the dm device will appear in "dm tree" but, no MTD devices will be found because spi_free_flash() will have removed the MTD device from mtd_idr. Fix this case by avoiding the spi_free_flash() call when DM_SPI_FLASH is true as we already do in cmd/sf.c. Signed-off-by: Bryan O'Donoghue --- env/sf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/env/sf.c b/env/sf.c index 5ef4055219..2563a1fbe4 100644 --- a/env/sf.c +++ b/env/sf.c @@ -178,7 +178,9 @@ static int env_sf_load(void) ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2, read2_fail); +#ifndef CONFIG_DM_SPI_FLASH spi_flash_free(env_flash); +#endif env_flash = NULL; out: free(tmp_env1);