diff options
author | Simon Glass <sjg@chromium.org> | 2011-11-17 14:30:06 -0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2011-11-18 16:21:36 -0800 |
commit | a4a24c8a87ee3121bde71dde04e58b699670761d (patch) | |
tree | 4fa930ff7a747881ae5a0941e77fc193834070c1 /common | |
parent | 318c9b21768d937e4a8984af86fec6fcd02242f2 (diff) |
Tidy up fdt_decode_alloc_region() to make alloc separate
Move the malloc() out of fdt_decode_alloc_region() and rename it
accordingly. This makes the code somewhat cleaner and allows us
to print a sensible error message.
BUG=chromium-os:17062
TEST=build and boot on Kaen
Change-Id: I8edc8809baa42578e74c5e42cf47494b31b774e7
Reviewed-on: https://gerrit.chromium.org/gerrit/11878
Commit-Ready: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/fdt_decode.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c index b6beebda69a..dab673a02cb 100644 --- a/common/fdt_decode.c +++ b/common/fdt_decode.c @@ -23,7 +23,6 @@ #include <fdt_decode.h> #include <libfdt.h> -#include <malloc.h> #include <serial.h> /* we need a generic GPIO interface here */ @@ -703,22 +702,19 @@ int fdt_decode_nand(const void *blob, int node, struct fdt_nand *config) return fdt_decode_gpio(blob, node, "wp-gpio", &config->wp_gpio); } -void *fdt_decode_alloc_region(const void *blob, int node, - const char *prop_name, size_t *size) +int fdt_decode_region(const void *blob, int node, + const char *prop_name, void **ptrp, size_t *size) { const addr_t *cell; - void *ptr; int len; debug("%s: %s\n", __func__, prop_name); cell = fdt_getprop(blob, node, prop_name, &len); if (!cell || (len != sizeof(addr_t) * 2)) - return NULL; + return -1; - ptr = (void *)addr_to_cpu(*cell); + *ptrp = (void *)addr_to_cpu(*cell); *size = size_to_cpu(cell[1]); debug("%s: size=%zx\n", __func__, *size); - if (!ptr) - ptr = malloc(*size); - return ptr; + return 0; } |