From a0ba216ed420a8953f57f777256f310370b95338 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 3 Sep 2021 15:16:25 +0200 Subject: [PATCH] ARM: tegra: Copy memory-region-names property If multiple entries are present in the memory-region property, this new memory-region-names property can be used to specify names for each of them so that they can be more easily distinguished. Signed-off-by: Thierry Reding Reviewed-by: Simon Glass Signed-off-by: Tom Warren --- arch/arm/mach-tegra/dt-setup.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-tegra/dt-setup.c b/arch/arm/mach-tegra/dt-setup.c index 894a6358a2..c11494722b 100644 --- a/arch/arm/mach-tegra/dt-setup.c +++ b/arch/arm/mach-tegra/dt-setup.c @@ -78,9 +78,11 @@ void ft_mac_address_setup(void *fdt) static int ft_copy_carveout(void *dst, const void *src, const char *node) { + const char *names = "memory-region-names"; struct fdt_memory carveout; unsigned int index = 0; - int err; + int err, offset, len; + const void *prop; while (true) { const char **compatibles = NULL; @@ -96,6 +98,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node) if (err != -FDT_ERR_NOTFOUND) printf("failed to get carveout for %s: %d\n", node, err); + else + break; return err; } @@ -126,6 +130,31 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node) index++; } + offset = fdt_path_offset(src, node); + if (offset < 0) { + debug("failed to find source offset for %s: %s\n", node, + fdt_strerror(err)); + return err; + } + + prop = fdt_getprop(src, offset, names, &len); + if (prop) { + offset = fdt_path_offset(dst, node); + if (offset < 0) { + debug("failed to find destination offset for %s: %s\n", + node, fdt_strerror(err)); + return err; + } + + err = fdt_setprop(dst, offset, "memory-region-names", prop, + len); + if (err < 0) { + debug("failed to copy \"%s\" property: %s\n", names, + fdt_strerror(err)); + return err; + } + } + return 0; } -- 2.39.5