From patchwork Wed Oct 23 14:46:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 1182218 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sntech.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ytXM428kz9sPV for ; Thu, 24 Oct 2019 01:48:03 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 25F1AC21E15; Wed, 23 Oct 2019 14:47:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5834AC21DB5; Wed, 23 Oct 2019 14:46:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 487C8C21C27; Wed, 23 Oct 2019 14:46:55 +0000 (UTC) Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lists.denx.de (Postfix) with ESMTPS id CD3E0C21C3F for ; Wed, 23 Oct 2019 14:46:54 +0000 (UTC) Received: from ip5f5a6266.dynamic.kabel-deutschland.de ([95.90.98.102] helo=phil.fritz.box) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1iNHuX-0001xl-M8; Wed, 23 Oct 2019 16:46:53 +0200 From: Heiko Stuebner To: u-boot@lists.denx.de Date: Wed, 23 Oct 2019 16:46:39 +0200 Message-Id: <20191023144641.5710-2-heiko@sntech.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023144641.5710-1-heiko@sntech.de> References: <20191023144641.5710-1-heiko@sntech.de> MIME-Version: 1.0 Cc: andre.przywara@arm.com, Heiko Stuebner , robin.murphy@arm.com, christoph.muellner@theobroma-systems.com Subject: [U-Boot] [PATCH v3 2/4] fdtdec: only create phandle if caller wants it in fdtdec_add_reserved_memory() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Heiko Stuebner The phandlep pointer returning the phandle to the caller is optional and if it is not set when calling fdtdec_add_reserved_memory() it is highly likely that the caller is not interested in a phandle to the created reserved-memory area and really just wants that area added. So just don't create a phandle in that case. Signed-off-by: Heiko Stuebner Reviewed-by: Simon Glass Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- changes in v2: - update function comment include/fdtdec.h | 2 +- lib/fdtdec.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 54509a25ad..fe8e7770ec 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -1078,7 +1078,7 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle) * @param basename base name of the node to create * @param carveout information about the carveout region * @param phandlep return location for the phandle of the carveout region - * can be NULL + * can be NULL if no phandle should be added * @return 0 on success or a negative error code on failure */ int fdtdec_add_reserved_memory(void *blob, const char *basename, diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d7c3684145..c841aafa2a 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1393,13 +1393,15 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, if (node < 0) return node; - err = fdt_generate_phandle(blob, &phandle); - if (err < 0) - return err; - - err = fdtdec_set_phandle(blob, node, phandle); - if (err < 0) - return err; + if (phandlep) { + err = fdt_generate_phandle(blob, &phandle); + if (err < 0) + return err; + + err = fdtdec_set_phandle(blob, node, phandle); + if (err < 0) + return err; + } /* store one or two address cells */ if (na > 1)