]> git.sur5r.net Git - u-boot/commitdiff
ARM: uniphier: avoid unaligned access to DT on 64bit SoC
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 21 Apr 2016 05:43:12 +0000 (14:43 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Sun, 24 Apr 2016 00:53:55 +0000 (09:53 +0900)
Because DT properties are 4-byte aligned, the pointer access
*(fdt64_t *) in this code causes unaligned access.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
arch/arm/mach-uniphier/dram_init.c

index 815f2433f38287eeb7b42d97178743780cf8e9eb..ef0e2e8f54c5ca89cc0d101ca229a4b9a5df8b3f 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <libfdt.h>
+#include <fdtdec.h>
 #include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -40,8 +41,7 @@ int dram_init(void)
 
        val += ac;
 
-       gd->ram_size = sc == 2 ? fdt64_to_cpu(*(fdt64_t *)val) :
-                                                       fdt32_to_cpu(*val);
+       gd->ram_size = fdtdec_get_number(val, sc);
 
        debug("DRAM size = %08lx\n", (unsigned long)gd->ram_size);
 
@@ -71,11 +71,9 @@ void dram_init_banksize(void)
 
        for (i = 0; i < CONFIG_NR_DRAM_BANKS && len >= cells;
             i++, len -= cells) {
-               gd->bd->bi_dram[i].start = ac == 2 ?
-                       fdt64_to_cpu(*(fdt64_t *)val) : fdt32_to_cpu(*val);
+               gd->bd->bi_dram[i].start = fdtdec_get_number(val, ac);
                val += ac;
-               gd->bd->bi_dram[i].size = sc == 2 ?
-                       fdt64_to_cpu(*(fdt64_t *)val) : fdt32_to_cpu(*val);
+               gd->bd->bi_dram[i].size = fdtdec_get_number(val, sc);
                val += sc;
 
                debug("DRAM bank %d: start = %08lx, size = %08lx\n",