static void karo_set_fdtsize(void *fdt)
{
- char fdt_size[9];
size_t fdtsize = getenv_ulong("fdtsize", 16, 0);
if (fdtsize == fdt_totalsize(fdt)) {
}
debug("FDT size changed from %u to %u\n",
fdtsize, fdt_totalsize(fdt));
-
- snprintf(fdt_size, sizeof(fdt_size), "%08x", fdt_totalsize(fdt));
- setenv("fdtsize", fdt_size);
+ setenv_hex("fdtsize", fdt_totalsize(fdt));
}
static int karo_load_part(const char *part, void *addr, size_t len)
int ret;
void *fdt = (void *)getenv_ulong("fdtaddr", 16, CONFIG_SYS_FDT_ADDR);
- if (tstc()) {
- debug("aborting DTB load\n");
+ if (had_ctrlc()) {
+ printf("aborting DTB load\n");
return NULL;
}
return;
}
+ setenv("fdtsize", 0);
+
if (!fdt_addr) {
fdt_addr = CONFIG_SYS_FDT_ADDR;
printf("fdtaddr is not set; using default: %08lx\n",
debug("Removing node '%s' from DT\n", node);
if (off < 0) {
- printf("Could not find node '%s': %d\n", node, off);
+ printf("Could not find node '%s': %s\n", node,
+ fdt_strerror(off));
} else {
ret = fdt_del_node(blob, off);
if (ret)
- printf("Failed to remove node '%s': %d\n",
- node, ret);
+ printf("Failed to remove node '%s': %s\n",
+ node, fdt_strerror(ret));
}
karo_set_fdtsize(blob);
}
debug("%sabling node '%s'\n", enable ? "En" : "Dis", node);
if (off < 0) {
- printf("Could not find node '%s': %d\n", node, off);
+ printf("Could not find node '%s': %s\n", node,
+ fdt_strerror(off));
return;
}
fdt_set_node_status(blob, off,
int offs = fdt_node_offset_by_compatible(blob, -1, name);
if (offs < 0) {
- debug("node '%s' not found: %d\n", name, offs);
+ debug("node '%s' not found: %s\n", name, fdt_strerror(offs));
return;
}
}
out:
if (ret)
- printf("Failed to update usbotg: %d\n", ret);
+ printf("Failed to update usbotg: %s\n", fdt_strerror(ret));
else
debug("node '%s' updated\n", node);
karo_set_fdtsize(blob);
ret = fdt_increase_size(blob, 64);
if (ret) {
- printf("Warning: Failed to increase FDT size: %d\n", ret);
+ printf("Warning: Failed to increase FDT size: %s\n",
+ fdt_strerror(ret));
}
debug("Creating phandle at offset %d\n", off);
ph = fdt_create_phandle(blob, off);
debug("parent offset=%06x\n", off);
ret = fdt_setprop_cell(blob, off, "native-mode", ph);
if (ret)
- printf("Failed to set property 'native-mode': %d\n", ret);
+ printf("Failed to set property 'native-mode': %s\n",
+ fdt_strerror(ret));
karo_set_fdtsize(blob);
return ret;
}
const char *subnode = "display-timings";
if (off < 0) {
- debug("Could not find node 'display' in FDT: %d\n", off);
+ debug("Could not find node 'display' in FDT: %s\n",
+ fdt_strerror(off));
return off;
}
off = fdt_subnode_offset(blob, off, subnode);
if (off < 0) {
- debug("Could not find node '%s' in FDT: %d\n", subnode, off);
+ debug("Could not find node '%s' in FDT: %s\n", subnode,
+ fdt_strerror(off));
}
return off;
}
if (d < 1)
return -EINVAL;
if (d > 2) {
- debug("Skipping node @ %04x %s depth %d\n", off, fdt_get_name(blob, off, NULL), d);
+ debug("Skipping node @ %04x %s depth %d\n", off,
+ fdt_get_name(blob, off, NULL), d);
continue;
}
- debug("parsing subnode @ %04x %s depth %d\n", off, fdt_get_name(blob, off, NULL), d);
+ debug("parsing subnode @ %04x %s depth %d\n", off,
+ fdt_get_name(blob, off, NULL), d);
n = fdt_getprop(blob, off, "panel-name", &len);
if (!n) {
int ret; \
ret = fdt_setprop_u32(blob, off, n, v); \
if (ret) { \
- printf("Failed to set property %s: %d\n", name, ret); \
+ printf("Failed to set property %s: %s\n", name, \
+ fdt_strerror(ret)); \
} \
ret; \
})
ret = fdt_increase_size(blob, 512);
if (ret) {
- printf("Failed to increase FDT size: %d\n", ret);
+ printf("Failed to increase FDT size: %s\n", fdt_strerror(ret));
return ret;
}
ret = fdt_subnode_offset(blob, off, subnode);
if (ret < 0) {
- debug("Could not find node '%s' in FDT: %d\n", subnode, ret);
+ debug("Could not find node '%s' in FDT: %s\n", subnode,
+ fdt_strerror(ret));
ret = fdt_add_subnode(blob, off, subnode);
if (ret < 0) {
- printf("Failed to add %s subnode: %d\n", subnode, ret);
+ printf("Failed to add %s subnode: %s\n", subnode,
+ fdt_strerror(ret));
return ret;
}
}
ret = fdt_add_subnode(blob, ret, name);
if (ret < 0) {
- printf("Failed to add %s subnode: %d\n", name, ret);
+ printf("Failed to add %s subnode: %s\n", name,
+ fdt_strerror(ret));
return ret;
}
off = ret;
}
}
ret = fdt_setprop_string(blob, off, "display", display);
- debug("setprop_string(display='%s') returned %d\n", display, ret);
+ debug("setprop_string(display='%s') returned %d (%s)\n", display, ret,
+ ret < 0 ? fdt_strerror(ret) : "OK");
return ret;
}
off = fdt_subnode_offset(blob, off, subnode);
if (off < 0) {
- debug("Could not find node '%s' in FDT: %d\n", subnode, off);
+ debug("Could not find node '%s' in FDT: %s\n", subnode,
+ fdt_strerror(off));
return off;
}
while (off > 0) {
if (d < 1)
return -EINVAL;
if (d > 2) {
- debug("Skipping node @ %04x %s depth %d\n", off, fdt_get_name(blob, off, NULL), d);
+ debug("Skipping node @ %04x %s depth %d\n", off,
+ fdt_get_name(blob, off, NULL), d);
continue;
}
- debug("parsing subnode @ %04x %s depth %d\n", off, fdt_get_name(blob, off, NULL), d);
+ debug("parsing subnode @ %04x %s depth %d\n", off,
+ fdt_get_name(blob, off, NULL), d);
n = fdt_getprop(blob, off, "panel-name", &len);
if (!n) {