fdt: Correct fdt_get_base_address()
authorSimon Glass <sjg@chromium.org>
Tue, 4 Jul 2017 19:31:20 +0000 (13:31 -0600)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 1 Aug 2017 02:58:00 +0000 (11:58 +0900)
This function appears to obtain the value of the 'ranges' property rather
than 'reg'. As such it does not behave as documented or expected.

In addition it picks up the second field of the property which is the size
(with prop += naddr) rather than the first which is the address.

Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/fdt_support.c

index 5aa8e34..7ccf8b1 100644 (file)
@@ -1464,14 +1464,11 @@ int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr)
 u64 fdt_get_base_address(const void *fdt, int node)
 {
        int size;
-       u32 naddr;
        const fdt32_t *prop;
 
-       naddr = fdt_address_cells(fdt, node);
+       prop = fdt_getprop(fdt, node, "reg", &size);
 
-       prop = fdt_getprop(fdt, node, "ranges", &size);
-
-       return prop ? fdt_translate_address(fdt, node, prop + naddr) : 0;
+       return prop ? fdt_translate_address(fdt, node, prop) : 0;
 }
 
 /*