All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fdt: Try to read #address-cells/size-cells from parent
@ 2016-02-10 12:04 Michal Simek
  2016-02-15  9:58 ` Michal Simek
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Simek @ 2016-02-10 12:04 UTC (permalink / raw)
  To: u-boot

Read #address-cells and #size-cells from parent if they are not present in
current node.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

I have code which read information about memory for zynqmp but memory
node most of the time doesn't contain #address/size-cells which are
present in parent node.
That's why let's try to read it from parent.

Also I think that we shouldn't return 2 if property is not found because
it has side effect on 32bit systems with #address/size-cells = <1>;

---
 lib/libfdt/fdt_addresses.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/libfdt/fdt_addresses.c b/lib/libfdt/fdt_addresses.c
index 76054d98e5fd..b164d0988079 100644
--- a/lib/libfdt/fdt_addresses.c
+++ b/lib/libfdt/fdt_addresses.c
@@ -19,10 +19,15 @@ int fdt_address_cells(const void *fdt, int nodeoffset)
 	const fdt32_t *ac;
 	int val;
 	int len;
+	int parent;
 
 	ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
-	if (!ac)
-		return 2;
+	if (!ac) {
+		parent = fdt_parent_offset(fdt, nodeoffset);
+		ac = fdt_getprop(fdt, parent, "#address-cells", &len);
+		if (!ac)
+			return 2;
+	}
 
 	if (len != sizeof(*ac))
 		return -FDT_ERR_BADNCELLS;
@@ -39,10 +44,15 @@ int fdt_size_cells(const void *fdt, int nodeoffset)
 	const fdt32_t *sc;
 	int val;
 	int len;
+	int parent;
 
 	sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
-	if (!sc)
-		return 2;
+	if (!sc) {
+		parent = fdt_parent_offset(fdt, nodeoffset);
+		sc = fdt_getprop(fdt, parent, "#size-cells", &len);
+		if (!sc)
+			return 2;
+	}
 
 	if (len != sizeof(*sc))
 		return -FDT_ERR_BADNCELLS;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-03-16 23:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-10 12:04 [U-Boot] [PATCH] fdt: Try to read #address-cells/size-cells from parent Michal Simek
2016-02-15  9:58 ` Michal Simek
2016-02-16 16:00   ` Simon Glass
2016-02-16 16:10     ` Michal Simek
     [not found]       ` <56C349E8.9030808-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2016-03-13  1:54         ` Simon Glass
2016-03-13  1:54           ` [U-Boot] " Simon Glass
2016-03-14 21:10           ` Michal Simek
2016-03-14 21:10             ` [U-Boot] " Michal Simek
     [not found]             ` <56E728E2.5050905-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2016-03-15  0:27               ` David Gibson
2016-03-15  0:27                 ` [U-Boot] " David Gibson
     [not found]                 ` <20160315002743.GC15272-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-03-16 16:18                   ` Michal Simek
2016-03-16 16:18                     ` [U-Boot] " Michal Simek
     [not found]                     ` <56E98751.4060007-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2016-03-16 22:47                       ` David Gibson
2016-03-16 22:47                         ` [U-Boot] " David Gibson
2016-03-16 23:21                         ` Michal Simek
2016-03-16 23:21                           ` [U-Boot] " Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.