From patchwork Fri Jul 17 01:46:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 235664 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1291106ilg; Thu, 16 Jul 2020 18:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcXLikZK9dUCCHOcFzJkys0vNbwAWvrE3noXMl0SMZAZjYbQEVYlz7thQmici5AgcJPXwc X-Received: by 2002:a05:6402:94f:: with SMTP id h15mr7232008edz.313.1594950422271; Thu, 16 Jul 2020 18:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594950422; cv=none; d=google.com; s=arc-20160816; b=sE9VFzEY98KxXLB3KesKaMDFb0ymef4RWWlR5azXGYJnJKvKAQdGQPu1S8jDzGXZEg VVDey6eSvS2BnIpAHVqRPN/ELmI/u9nNMYdRTmMZXYE/uhlwy9Z3qU2XmBQfIEdVPPVd HbXVqNxciqRTrZt+vl/sJmHdMCYGl2+p3yjWsOrxDduNNiVKsmGE1M4YukFmXqzgxdF+ 1ynMK3bt0oHC60VFYcHm53XY07pGDGUmii9TRSLYayR7UgR7fkr8/Kmzq07JqHYC+0RH Vca9hYZ9FYwGgvrHMljtgqJ7mGqam+eoTf3lV7IqgXm7qjWpXNNUopKmaHx1k3KaH5ZR dYTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=gmTxS135nRLvOhBXkQeqGgS6HxmjDIz+lp/EDeUIYpA=; b=BUnIcwjNLWrqnYAe4Um0WTAhN3nYlv2fZU38+7WCdYQZAiVXXTQTht4pF8OJQ+TayJ mnLMGpjuhOTOQCgXWNbOFc7jBNru8rDrZX8jObWFkF+rcGx72Jol7sN8Mw+mFEsJq6AF CjcaEfpsx/eAexQdh3+c1qNaJqb2zg/Jfhf81s9BZOUq+yGfJHC5Ovc0He63S8Ghelm3 u2L23GOkUlWzVFcnk8GTdofUY5dEFu+tLIcfFXZvRM+QTHq/ktjBKt1Zm6XAdouNyhg8 9vzRZnmZnV0lL0BbGkiSkZDSHv3Ul71L9cLrwn6U3eAJOBwaMlKeAl8OLXLKjXPCm4HH gvDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=HVSSdA9r; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id k20si4137808ejq.621.2020.07.16.18.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 18:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=HVSSdA9r; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0259D81BF7; Fri, 17 Jul 2020 03:47:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="HVSSdA9r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE73A81BFF; Fri, 17 Jul 2020 03:46:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) (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 80B8781B6E for ; Fri, 17 Jul 2020 03:46:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=yamada.masahiro@socionext.com Received: from oscar.flets-west.jp (softbank126025067101.bbtec.net [126.25.67.101]) (authenticated) by conuserg-08.nifty.com with ESMTP id 06H1kPAn008623; Fri, 17 Jul 2020 10:46:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 06H1kPAn008623 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1594950386; bh=gmTxS135nRLvOhBXkQeqGgS6HxmjDIz+lp/EDeUIYpA=; h=From:To:Cc:Subject:Date:From; b=HVSSdA9rgPYxfVqsTthJN94kdI6QMNo6VUVJcA1AfcHEP0yLMT0/umUhQrHa7tzAY iNifkNxTBM9sJF0WTjlXYV5FrdQ3not2Ts4vKGpAxC5e3Zd2F+la7C+9hiEEygzw10 IOJG+YuZSxrAD1h1m01VByiJrTau2qIBqhmhVXGmubpltXPItkaX9lSw7wHlO7z63+ 1It6YoQLQmHwgXjp2i527HihkI+i/byx1iDG+5sjs8mSjgh53uZm46oVe/hfPawpN/ mOmxBrBoS6KVQRwAd26j7VngjpnGe0/DZOhzNjqdJ+NIzJTT4et4Ghc9V0HImcqyJM TgBlk5KZfCIEA== X-Nifty-SrcIP: [126.25.67.101] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Masahiro Yamada , Simon Glass Subject: [PATCH v2 1/2] fdt_support: call mtdparts_init() after finding MTD node to fix up Date: Fri, 17 Jul 2020 10:46:18 +0900 Message-Id: <20200717014619.756044-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Platform code can call fdt_fixup_mtdparts() in order to hand U-Boot's MTD partitions over to the Linux device tree. Currently, fdt_fixup_mtdparts() calls mtdparts_init() in its entry. If no target MTD device is found, an error message like follows is displayed: Device nand0 not found! This occurs when the same code (e.g. arch/arm/mach-uniphier/fdt-fixup.c) is shared among several boards, but not all of them support an MTD device. Parse the DT first, then call mtdparts_init() only when the target MTD node is found. Yet, you still need to call mtdparts_init() before device_find(). Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- Changes in v2: - rename 'initialized' to 'inited' common/fdt_support.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.25.1 diff --git a/common/fdt_support.c b/common/fdt_support.c index 3778de5368..cf09c3c5fb 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -951,9 +951,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, struct mtd_device *dev; int i, idx; int noff; - - if (mtdparts_init() != 0) - return; + bool inited = false; for (i = 0; i < node_info_size; i++) { idx = 0; @@ -963,6 +961,13 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, debug("%s: %s, mtd dev type %d\n", fdt_get_name(blob, noff, 0), node_info[i].compat, node_info[i].type); + + if (!inited) { + if (mtdparts_init() != 0) + return; + inited = true; + } + dev = device_find(node_info[i].type, idx++); if (dev) { if (fdt_node_set_part_info(blob, noff, dev))