]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fdt: Try to read address-cells/size-cells from parent
authorMichal Simek <michal.simek@xilinx.com>
Wed, 10 Feb 2016 11:46:23 +0000 (12:46 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 11 Feb 2016 15:30:44 +0000 (16:30 +0100)
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>
lib/libfdt/fdt_addresses.c

index 76054d98e5fd7b368e3ce5e9e7c40c899b82994a..b164d09880798b528a332c5c3ea3b11859aecadf 100644 (file)
@@ -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;