From patchwork Fri Jul 26 09:13:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 1137330 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 (mailfrom) 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=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="zkN4jqRm"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45w3Ks4YJXz9s8m for ; Fri, 26 Jul 2019 19:13:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4B51BC21D8A; Fri, 26 Jul 2019 09:13:51 +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=T_DKIM_INVALID 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 78DD1C21C2F; Fri, 26 Jul 2019 09:13:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 88091C21C2F; Fri, 26 Jul 2019 09:13:47 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by lists.denx.de (Postfix) with ESMTPS id 33FDEC21C3F for ; Fri, 26 Jul 2019 09:13:47 +0000 (UTC) Received: from ziggy.de (unknown [37.223.144.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D0DE22BE8; Fri, 26 Jul 2019 09:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564132426; bh=8BvJeiHjsW4nk2UxaQB0Mh+nnesTZw/3ULaJ34G84IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zkN4jqRmvAxLSvy60lBtU9Ao+7pJ1caPR7wSE/Z/XeWpG9b/mgMfHjnyFu8qdYHlm oT7CsRe8T0PMhWAN61gBTQ5AxMYdDrC5FgXqB/z5t1Tq4/OcbUm/xSxv+wI5fWqvbt MdG8rCq8PIiLMemYLgC1f4HP+bMeMSjUHW3/2kOA= From: matthias.bgg@kernel.org To: treding@nvidia.com, sjg@chromium.org Date: Fri, 26 Jul 2019 11:13:39 +0200 Message-Id: <20190726091339.24420-2-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190726091339.24420-1-matthias.bgg@kernel.org> References: <20190726091339.24420-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, Matthias Brugger Subject: [U-Boot] [PATCH 2/2] libfdt: return correct value if #size-cells property is not present 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: Matthias Brugger According to the device tree specification, the default value for was not present. This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned. This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in u-boot. Signed-off-by: Matthias Brugger --- scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c index 49537b578d..f13a87dfa0 100644 --- a/scripts/dtc/libfdt/fdt_addresses.c +++ b/scripts/dtc/libfdt/fdt_addresses.c @@ -64,7 +64,7 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name) c = fdt_getprop(fdt, nodeoffset, name, &len); if (!c) - return 2; + return len; if (len != sizeof(*c)) return -FDT_ERR_BADNCELLS; @@ -78,10 +78,20 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name) int fdt_address_cells(const void *fdt, int nodeoffset) { - return fdt_cells(fdt, nodeoffset, "#address-cells"); + int val; + + val = fdt_cells(fdt, nodeoffset, "#address-cells"); + if (val == -FDT_ERR_NOTFOUND) + return 2; + return val; } int fdt_size_cells(const void *fdt, int nodeoffset) { - return fdt_cells(fdt, nodeoffset, "#size-cells"); + int val; + + val = fdt_cells(fdt, nodeoffset, "#size-cells"); + if (val == -FDT_ERR_NOTFOUND) + return 1; + return val; } diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h index 66f01fec53..5c778b115b 100644 --- a/scripts/dtc/libfdt/libfdt.h +++ b/scripts/dtc/libfdt/libfdt.h @@ -1109,7 +1109,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset); * * returns: * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #size-cells property + * 1, if the node has no #size-cells property * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid * #size-cells property * -FDT_ERR_BADMAGIC,