]> git.sur5r.net Git - u-boot/blobdiff - cmd/fdt.c
Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[u-boot] / cmd / fdt.c
index 7af9bfec5fc251d3ce273edf2e3d41a3d831407a..28de467f9671e6dffcbc18a74522114509036f57 100644 (file)
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2007
  * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
  * Based on code written by:
  *   Pantelis Antoniou <pantelis.antoniou@gmail.com> and
  *   Matthew McClintock <msm@freescale.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -13,7 +12,7 @@
 #include <linux/ctype.h>
 #include <linux/types.h>
 #include <asm/global_data.h>
-#include <libfdt.h>
+#include <linux/libfdt.h>
 #include <fdt_support.h>
 #include <mapmem.h>
 #include <asm/io.h>
@@ -43,7 +42,7 @@ void set_working_fdt_addr(ulong addr)
 
        buf = map_sysmem(addr, 0);
        working_fdt = buf;
-       setenv_hex("fdtaddr", addr);
+       env_set_hex("fdtaddr", addr);
 }
 
 /*
@@ -111,7 +110,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                return 1;
                        printf("The address of the fdt is %#08lx\n",
                               control ? (ulong)map_to_sysmem(blob) :
-                                       getenv_hex("fdtaddr", 0));
+                                       env_get_hex("fdtaddr", 0));
                        return 0;
                }
 
@@ -256,7 +255,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                char *pathp;            /* path */
                char *prop;             /* property */
                int  nodeoffset;        /* node offset from libfdt */
-               static char data[SCRATCHPAD];   /* storage for the property */
+               static char data[SCRATCHPAD] __aligned(4);/* property storage */
                const void *ptmp;
                int  len;               /* new length of the property */
                int  ret;               /* return value */
@@ -284,16 +283,14 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        len = 0;
                } else {
                        ptmp = fdt_getprop(working_fdt, nodeoffset, prop, &len);
-                       if (!ptmp) {
-                               printf("prop (%s) not found!\n", prop);
-                               return 1;
-                       }
                        if (len > SCRATCHPAD) {
                                printf("prop (%d) doesn't fit in scratchpad!\n",
                                       len);
                                return 1;
                        }
-                       memcpy(data, ptmp, len);
+                       if (ptmp != NULL)
+                               memcpy(data, ptmp, len);
+
                        ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
                        if (ret != 0)
                                return ret;
@@ -373,7 +370,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        }
                        if (subcmd[0] == 's') {
                                /* get the num nodes at this level */
-                               setenv_ulong(var, curIndex + 1);
+                               env_set_ulong(var, curIndex + 1);
                        } else {
                                /* node index not found */
                                printf("libfdt node not found\n");
@@ -669,11 +666,10 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                if (!fdt_valid(&blob))
                        return CMD_RET_FAILURE;
 
-               ret = fdt_overlay_apply(working_fdt, blob);
-               if (ret) {
-                       printf("fdt_overlay_apply(): %s\n", fdt_strerror(ret));
+               /* apply method prints messages on error */
+               ret = fdt_overlay_apply_verbose(working_fdt, blob);
+               if (ret)
                        return CMD_RET_FAILURE;
-               }
        }
 #endif
        /* resize the fdt */