projects
/
platform
/
kernel
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cmd: Add command for calculating binary operations
[platform/kernel/u-boot.git]
/
cmd
/
fdt.c
diff --git
a/cmd/fdt.c
b/cmd/fdt.c
index
31a5361
..
65661fa
100644
(file)
--- a/
cmd/fdt.c
+++ b/
cmd/fdt.c
@@
-13,7
+13,7
@@
#include <linux/ctype.h>
#include <linux/types.h>
#include <asm/global_data.h>
#include <linux/ctype.h>
#include <linux/types.h>
#include <asm/global_data.h>
-#include <libfdt.h>
+#include <li
nux/li
bfdt.h>
#include <fdt_support.h>
#include <mapmem.h>
#include <asm/io.h>
#include <fdt_support.h>
#include <mapmem.h>
#include <asm/io.h>
@@
-43,21
+43,21
@@
void set_working_fdt_addr(ulong addr)
buf = map_sysmem(addr, 0);
working_fdt = buf;
buf = map_sysmem(addr, 0);
working_fdt = buf;
-
setenv
_hex("fdtaddr", addr);
+
env_set
_hex("fdtaddr", addr);
}
/*
* Get a value from the fdt and format it to be set in the environment
*/
}
/*
* Get a value from the fdt and format it to be set in the environment
*/
-static int fdt_value_
setenv
(const void *nodep, int len, const char *var)
+static int fdt_value_
env_set
(const void *nodep, int len, const char *var)
{
if (is_printable_string(nodep, len))
{
if (is_printable_string(nodep, len))
-
setenv
(var, (void *)nodep);
+
env_set
(var, (void *)nodep);
else if (len == 4) {
char buf[11];
sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
else if (len == 4) {
char buf[11];
sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
-
setenv
(var, buf);
+
env_set
(var, buf);
} else if (len%4 == 0 && len <= 20) {
/* Needed to print things like sha1 hashes. */
char buf[41];
} else if (len%4 == 0 && len <= 20) {
/* Needed to print things like sha1 hashes. */
char buf[41];
@@
-66,7
+66,7
@@
static int fdt_value_setenv(const void *nodep, int len, const char *var)
for (i = 0; i < len; i += sizeof(unsigned int))
sprintf(buf + (i * 2), "%08x",
*(unsigned int *)(nodep + i));
for (i = 0; i < len; i += sizeof(unsigned int))
sprintf(buf + (i * 2), "%08x",
*(unsigned int *)(nodep + i));
-
setenv
(var, buf);
+
env_set
(var, buf);
} else {
printf("error: unprintable value\n");
return 1;
} else {
printf("error: unprintable value\n");
return 1;
@@
-111,7
+111,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) :
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;
}
return 0;
}
@@
-256,7
+256,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 */
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 */
const void *ptmp;
int len; /* new length of the property */
int ret; /* return value */
@@
-289,7
+289,9
@@
static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
len);
return 1;
}
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;
ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
if (ret != 0)
return ret;
@@
-354,10
+356,12
@@
static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (curDepth == startDepth + 1)
curIndex++;
if (subcmd[0] == 'n' && curIndex == reqIndex) {
if (curDepth == startDepth + 1)
curIndex++;
if (subcmd[0] == 'n' && curIndex == reqIndex) {
- const char *nodeName = fdt_get_name(
- working_fdt, nextNodeOffset, NULL);
+ const char *node_name;
- setenv(var, (char *)nodeName);
+ node_name = fdt_get_name(working_fdt,
+ nextNodeOffset,
+ NULL);
+ env_set(var, node_name);
return 0;
}
nextNodeOffset = fdt_next_node(
return 0;
}
nextNodeOffset = fdt_next_node(
@@
-367,7
+371,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 */
}
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");
} else {
/* node index not found */
printf("libfdt node not found\n");
@@
-378,13
+382,14
@@
static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
working_fdt, nodeoffset, prop, &len);
if (len == 0) {
/* no property value */
working_fdt, nodeoffset, prop, &len);
if (len == 0) {
/* no property value */
-
setenv
(var, "");
+
env_set
(var, "");
return 0;
} else if (nodep && len > 0) {
if (subcmd[0] == 'v') {
int ret;
return 0;
} else if (nodep && len > 0) {
if (subcmd[0] == 'v') {
int ret;
- ret = fdt_value_setenv(nodep, len, var);
+ ret = fdt_value_env_set(nodep, len,
+ var);
if (ret != 0)
return ret;
} else if (subcmd[0] == 'a') {
if (ret != 0)
return ret;
} else if (subcmd[0] == 'a') {
@@
-392,13
+397,13
@@
static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
char buf[11];
sprintf(buf, "0x%p", nodep);
char buf[11];
sprintf(buf, "0x%p", nodep);
-
setenv
(var, buf);
+
env_set
(var, buf);
} else if (subcmd[0] == 's') {
/* Get size */
char buf[11];
sprintf(buf, "0x%08X", len);
} else if (subcmd[0] == 's') {
/* Get size */
char buf[11];
sprintf(buf, "0x%08X", len);
-
setenv
(var, buf);
+
env_set
(var, buf);
} else
return CMD_RET_USAGE;
return 0;
} else
return CMD_RET_USAGE;
return 0;
@@
-662,11
+667,10
@@
static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (!fdt_valid(&blob))
return CMD_RET_FAILURE;
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;
return CMD_RET_FAILURE;
- }
}
#endif
/* resize the fdt */
}
#endif
/* resize the fdt */