[PATCH 2/4] fdtdec: Update fdtdec_setup_mem_size_base_fdt() to call fdtdec_get_mem_size_base()

Bin Meng bmeng.cn at gmail.com
Thu Jul 16 05:23:01 CEST 2020


From: Bin Meng <bin.meng at windriver.com>

The only difference betwen fdtdec_setup_mem_size_base_fdt() and
fdtdec_get_mem_size_base() is that the former does the assignment
to gd->ram_size and gd->ram_base.

Simplify the codes to call fdtdec_get_mem_size_base() directly.

Signed-off-by: Bin Meng <bin.meng at windriver.com>
---

 lib/fdtdec.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 078ff7a..015df84 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1056,23 +1056,12 @@ int fdtdec_get_mem_size_base(const void *blob,
 
 int fdtdec_setup_mem_size_base_fdt(const void *blob)
 {
-	int ret, mem;
-	struct fdt_resource res;
-
-	mem = fdt_path_offset(blob, "/memory");
-	if (mem < 0) {
-		debug("%s: Missing /memory node\n", __func__);
-		return -EINVAL;
-	}
+	int ret;
 
-	ret = fdt_get_resource(blob, mem, "reg", 0, &res);
-	if (ret != 0) {
-		debug("%s: Unable to decode first memory bank\n", __func__);
-		return -EINVAL;
-	}
+	ret = fdtdec_get_mem_size_base(blob, &gd->ram_size, &gd->ram_base);
+	if (ret)
+		return ret;
 
-	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
-	gd->ram_base = (unsigned long)res.start;
 	debug("%s: Initial DRAM size %llx\n", __func__,
 	      (unsigned long long)gd->ram_size);
 
-- 
2.7.4



More information about the U-Boot mailing list