Revert "fdt: Fix fdtdec_get_addr_size() for 64-bit"

This reverts commit 5b34436035.

This function has a few problems. It calls fdt_parent_offset() which as
mentioned in code review is very slow.

https://patchwork.ozlabs.org/patch/499482/
https://patchwork.ozlabs.org/patch/452604/

It also happens to break SPI flash on Minnowboard max which is how I noticed
that this was applied. I can send a patch to tidy that up, but in any case
I think we should consider a revert until the function is better implemented.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2015-08-02 18:13:50 -06:00
parent 590870e7e8
commit 236efe36be
1 changed files with 19 additions and 35 deletions

View File

@ -90,45 +90,29 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id)
fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
const char *prop_name, fdt_size_t *sizep) const char *prop_name, fdt_size_t *sizep)
{ {
const fdt32_t *ptr, *end; const fdt_addr_t *cell;
int parent, na, ns, len; int len;
fdt_addr_t addr;
debug("%s: %s: ", __func__, prop_name); debug("%s: %s: ", __func__, prop_name);
cell = fdt_getprop(blob, node, prop_name, &len);
if (cell && ((!sizep && len == sizeof(fdt_addr_t)) ||
len == sizeof(fdt_addr_t) * 2)) {
fdt_addr_t addr = fdt_addr_to_cpu(*cell);
if (sizep) {
const fdt_size_t *size;
parent = fdt_parent_offset(blob, node); size = (fdt_size_t *)((char *)cell +
if (parent < 0) { sizeof(fdt_addr_t));
debug("(no parent found)\n"); *sizep = fdt_size_to_cpu(*size);
return FDT_ADDR_T_NONE; debug("addr=%08lx, size=%llx\n",
(ulong)addr, (u64)*sizep);
} else {
debug("%08lx\n", (ulong)addr);
}
return addr;
} }
debug("(not found)\n");
na = fdt_address_cells(blob, parent); return FDT_ADDR_T_NONE;
ns = fdt_size_cells(blob, parent);
ptr = fdt_getprop(blob, node, prop_name, &len);
if (!ptr) {
debug("(not found)\n");
return FDT_ADDR_T_NONE;
}
end = ptr + len / sizeof(*ptr);
if (ptr + na + ns > end) {
debug("(not enough data: expected %d bytes, got %d bytes)\n",
(na + ns) * 4, len);
return FDT_ADDR_T_NONE;
}
addr = fdtdec_get_number(ptr, na);
if (sizep) {
*sizep = fdtdec_get_number(ptr + na, ns);
debug("addr=%pa, size=%pa\n", &addr, sizep);
} else {
debug("%pa\n", &addr);
}
return addr;
} }
fdt_addr_t fdtdec_get_addr(const void *blob, int node, fdt_addr_t fdtdec_get_addr(const void *blob, int node,