X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=common%2Fcmd_fdt.c;h=ac77a08b77d41cbb8c3753570c04bc45d407989c;hb=00a0ca5986c13d24ebbc5000cc1b7a1cdac0ba4b;hp=a5e2cfcbfa8ede2fffd84d5ef1beb13e7f75ff8b;hpb=71724830b42f67ea9633324183bb622724eee9cd;p=u-boot diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index a5e2cfcbfa..ac77a08b77 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -56,12 +55,8 @@ struct fdt_header *working_fdt; void set_working_fdt_addr(void *addr) { - char buf[17]; - working_fdt = addr; - - sprintf(buf, "%lx", (unsigned long)addr); - setenv("fdtaddr", buf); + setenv_addr("fdtaddr", addr); } /* @@ -95,7 +90,7 @@ static int fdt_value_setenv(const void *nodep, int len, const char *var) /* * Flattened Device Tree command, see the help for parameter definitions. */ -int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) return CMD_RET_USAGE; @@ -348,10 +343,7 @@ 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 */ - char buf[11]; - - sprintf(buf, "%d", curIndex + 1); - setenv(var, buf); + setenv_ulong(var, curIndex + 1); } else { /* node index not found */ printf("libfdt node not found\n"); @@ -375,7 +367,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) /* Get address */ char buf[11]; - sprintf(buf, "0x%08X", (uint32_t)nodep); + sprintf(buf, "0x%p", nodep); setenv(var, buf); } else if (subcmd[0] == 's') { /* Get size */ @@ -682,7 +674,7 @@ static int fdt_parse_prop(char * const *newval, int count, char *data, int *len) cp = newp; tmp = simple_strtoul(cp, &newp, 0); - *(uint32_t *)data = __cpu_to_be32(tmp); + *(__be32 *)data = __cpu_to_be32(tmp); data += 4; *len += 4; @@ -816,9 +808,9 @@ static void print_data(const void *data, int len) if ((len %4) == 0) { if (len > CONFIG_CMD_FDT_MAX_DUMP) - printf("* 0x%08x [0x%08x]", (unsigned int)data, len); + printf("* 0x%p [0x%08x]", data, len); else { - const u32 *p; + const __be32 *p; printf("<"); for (j = 0, p = data; j < len/4; j++) @@ -828,7 +820,7 @@ static void print_data(const void *data, int len) } } else { /* anything else... hexdump */ if (len > CONFIG_CMD_FDT_MAX_DUMP) - printf("* 0x%08x [0x%08x]", (unsigned int)data, len); + printf("* 0x%p [0x%08x]", data, len); else { const u8 *s; @@ -964,11 +956,9 @@ static int fdt_print(const char *pathp, char *prop, int depth) } /********************************************************************/ - -U_BOOT_CMD( - fdt, 255, 0, do_fdt, - "flattened device tree utility commands", - "addr [] - Set the fdt location to \n" +#ifdef CONFIG_SYS_LONGHELP +static char fdt_help_text[] = + "addr [] - Set the fdt location to \n" #ifdef CONFIG_OF_BOARD_SETUP "fdt boardsetup - Do board-specific set up\n" #endif @@ -992,5 +982,10 @@ U_BOOT_CMD( "fdt chosen [ ] - Add/update the /chosen branch in the tree\n" " / - initrd start/end addr\n" "NOTE: Dereference aliases by omiting the leading '/', " - "e.g. fdt print ethernet0." + "e.g. fdt print ethernet0."; +#endif + +U_BOOT_CMD( + fdt, 255, 0, do_fdt, + "flattened device tree utility commands", fdt_help_text );