diff options
author | Thierry Reding <treding@nvidia.com> | 2021-09-03 15:16:18 +0200 |
---|---|---|
committer | Tom Warren <twarren@nvidia.com> | 2021-10-13 14:18:30 -0700 |
commit | 4bf88ba76abb224b3ca258a2f502384ec6c86bd6 (patch) | |
tree | 74ac3ca45b7a69addd61faf887b20a175e92aa16 /lib/fdtdec.c | |
parent | d5598cfa9bcab50812b2b416af91c2a37be67531 (diff) |
fdtdec: Support retrieving the name of a carveout
When retrieving a given carveout for a device, allow callers to query
the name. This helps differentiating between carveouts when there are
more than one.
This is also useful when copying carveouts to help assign a meaningful
name that cannot always be guessed.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r-- | lib/fdtdec.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index f2861eb395..3ada77d80c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1406,8 +1406,9 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, return 0; } -int fdtdec_get_carveout(const void *blob, const char *node, const char *name, - unsigned int index, struct fdt_memory *carveout) +int fdtdec_get_carveout(const void *blob, const char *node, + const char *prop_name, unsigned int index, + struct fdt_memory *carveout, const char **name) { const fdt32_t *prop; uint32_t phandle; @@ -1418,9 +1419,9 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name, if (offset < 0) return offset; - prop = fdt_getprop(blob, offset, name, &len); + prop = fdt_getprop(blob, offset, prop_name, &len); if (!prop) { - debug("failed to get %s for %s\n", name, node); + debug("failed to get %s for %s\n", prop_name, node); return -FDT_ERR_NOTFOUND; } @@ -1442,6 +1443,9 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name, return offset; } + if (name) + *name = fdt_get_name(blob, offset, NULL); + carveout->start = fdtdec_get_addr_size_auto_noparent(blob, offset, "reg", 0, &size, true); |