From patchwork Wed May 20 06:38:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 246074 List-Id: U-Boot discussion From: bmeng.cn at gmail.com (Bin Meng) Date: Tue, 19 May 2020 23:38:32 -0700 Subject: [PATCH 1/2] fdtdec: Fix the types of addr and size in fdtdec_add_reserved_memory() Message-ID: <1589956713-5175-1-git-send-email-bmeng.cn@gmail.com> From: Bin Meng fdtdec_get_addr_size() expects size is of type 'fdt_size_t', and return value is of type 'fdt_addr_t'. Adjust their types accordingly. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 9c4d571..2d8ef65 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1294,7 +1294,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, /* find a matching node and return the phandle to that */ fdt_for_each_subnode(node, blob, parent) { const char *name = fdt_get_name(blob, node, NULL); - phys_addr_t addr, size; + fdt_addr_t addr; + fdt_size_t size; addr = fdtdec_get_addr_size(blob, node, "reg", &size); if (addr == FDT_ADDR_T_NONE) { From patchwork Wed May 20 06:38:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 246075 List-Id: U-Boot discussion From: bmeng.cn at gmail.com (Bin Meng) Date: Tue, 19 May 2020 23:38:33 -0700 Subject: [PATCH 2/2] fdtdec: Honor #address-cells and #size-cells in fdtdec_add_reserved_memory() In-Reply-To: <1589956713-5175-1-git-send-email-bmeng.cn@gmail.com> References: <1589956713-5175-1-git-send-email-bmeng.cn@gmail.com> Message-ID: <1589956713-5175-2-git-send-email-bmeng.cn@gmail.com> From: Bin Meng At present fdtdec_add_reserved_memory() calls fdtdec_get_addr_size() to get address and size for the subnodes of /reserved-memory node. We should honor #address-cells and #size-cells properties in the parent node. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 2d8ef65..3bfb462 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1297,7 +1297,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, fdt_addr_t addr; fdt_size_t size; - addr = fdtdec_get_addr_size(blob, node, "reg", &size); + addr = fdtdec_get_addr_size_fixed(blob, node, "reg", 0, na, ns, + &size, false); if (addr == FDT_ADDR_T_NONE) { debug("failed to read address/size for %s\n", name); continue;