[PATCH 9/9] ARM: tegra: Copy memory-region-names property

Thierry Reding thierry.reding at gmail.com
Fri Sep 3 15:16:25 CEST 2021


From: Thierry Reding <treding at nvidia.com>

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 <treding at nvidia.com>
---
 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 894a6358a2c4..c11494722bc7 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.33.0



More information about the U-Boot mailing list