diff mbox series

[2/2] fdt: fdtdec_setup_memory_banksize() use livetree

Message ID 20180810125410.19393-3-jens.wiklander@linaro.org
State Superseded
Headers show
Series Convert fdtdec_setup_memory_banksize() to use livetree | expand

Commit Message

Jens Wiklander Aug. 10, 2018, 12:54 p.m. UTC
Converts fdtdec_setup_memory_banksize() to use ofnode functions instead.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

---
 lib/fdtdec.c | 46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

-- 
2.17.1

Comments

Simon Glass Aug. 17, 2018, 12:48 p.m. UTC | #1
On 10 August 2018 at 06:54, Jens Wiklander <jens.wiklander@linaro.org> wrote:
> Converts fdtdec_setup_memory_banksize() to use ofnode functions instead.
>
> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> ---
>  lib/fdtdec.c | 46 +++++++++++++++++++++-------------------------
>  1 file changed, 21 insertions(+), 25 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Sept. 18, 2018, 2:05 a.m. UTC | #2
Hi Jen,

On 17 August 2018 at 14:48, Simon Glass <sjg@chromium.org> wrote:
>
> On 10 August 2018 at 06:54, Jens Wiklander <jens.wiklander@linaro.org> wrote:
> > Converts fdtdec_setup_memory_banksize() to use ofnode functions instead.
> >
> > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> > ---
> >  lib/fdtdec.c | 46 +++++++++++++++++++++-------------------------
> >  1 file changed, 21 insertions(+), 25 deletions(-)
> >
>
> Reviewed-by: Simon Glass <sjg@chromium.org>


Can you please rebase this on u-boot-dm/testing and resent? It seems
to conflict with an existing patch.

Thanks,
Simon
Jens Wiklander Sept. 25, 2018, 5:56 a.m. UTC | #3
Hi Simon,

On Tue, Sep 18, 2018 at 4:05 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Jen,
>
> On 17 August 2018 at 14:48, Simon Glass <sjg@chromium.org> wrote:
>>
>> On 10 August 2018 at 06:54, Jens Wiklander <jens.wiklander@linaro.org> wrote:
>> > Converts fdtdec_setup_memory_banksize() to use ofnode functions instead.
>> >
>> > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
>> > ---
>> >  lib/fdtdec.c | 46 +++++++++++++++++++++-------------------------
>> >  1 file changed, 21 insertions(+), 25 deletions(-)
>> >
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>
>
> Can you please rebase this on u-boot-dm/testing and resent? It seems
> to conflict with an existing patch.

I'm sorry, missed this one. It seems it's already been done by now.

Thanks,
Jens
diff mbox series

Patch

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index a208589c48ae..fef2f88f9d10 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -16,6 +16,7 @@ 
 #include <serial.h>
 #include <asm/sections.h>
 #include <linux/ctype.h>
+#include <linux/ioport.h>
 #include <linux/lzo.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -1182,43 +1183,34 @@  int fdtdec_setup_mem_size_base(void)
 
 #if defined(CONFIG_NR_DRAM_BANKS)
 
-static int get_next_memory_node(const void *blob, int startoffset)
+static ofnode get_next_memory_node(ofnode mem)
 {
-	int mem = -1;
-
 	do {
-		mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem,
-						    "device_type", "memory", 7);
-	} while (!fdtdec_get_is_enabled(blob, mem));
+		mem = ofnode_by_prop_value(mem, "device_type", "memory", 7);
+	} while (ofnode_valid(mem) && !ofnode_is_available(mem));
 
 	return mem;
 }
 
 int fdtdec_setup_memory_banksize(void)
 {
-	int bank, ret, mem, reg = 0;
-	struct fdt_resource res;
+	int bank, reg = 0;
+	struct resource res;
+	ofnode mem;
 
-	mem = get_next_memory_node(gd->fdt_blob, -1);
-	if (mem < 0) {
-		debug("%s: Missing /memory node\n", __func__);
-		return -EINVAL;
-	}
+	mem = get_next_memory_node(ofnode_null());
+	if (!ofnode_valid(mem))
+		goto missing_node;
 
 	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
-		if (ret == -FDT_ERR_NOTFOUND) {
+		while (ofnode_read_resource(mem, reg++, &res)) {
 			reg = 0;
-			mem = get_next_memory_node(gd->fdt_blob, mem);
-			if (mem == -FDT_ERR_NOTFOUND)
-				break;
-
-			ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
-			if (ret == -FDT_ERR_NOTFOUND)
-				break;
-		}
-		if (ret != 0) {
-			return -EINVAL;
+			mem = get_next_memory_node(mem);
+			if (!ofnode_valid(mem)) {
+				if (bank)
+					return 0;
+				goto missing_node;
+			}
 		}
 
 		gd->bd->bi_dram[bank].start = (phys_addr_t)res.start;
@@ -1232,6 +1224,10 @@  int fdtdec_setup_memory_banksize(void)
 	}
 
 	return 0;
+
+missing_node:
+	debug("%s: Missing /memory node\n", __func__);
+	return -EINVAL;
 }
 #endif