[Skiboot] [PATCH 9/9] npu2: Replace open coded dt_find_by_name_addr()

Reza Arbab arbab at linux.ibm.com
Thu Jan 10 02:58:51 AEDT 2019


We now have a dt function to do this. Use it.

Signed-off-by: Reza Arbab <arbab at linux.ibm.com>
---
 hw/npu2.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/hw/npu2.c b/hw/npu2.c
index 68a5382..d6b634d 100644
--- a/hw/npu2.c
+++ b/hw/npu2.c
@@ -605,20 +605,9 @@ static void npu2_append_phandle(struct dt_node *dn,
 static struct dt_node *npu2_create_memory_dn(uint64_t addr, uint64_t size)
 {
 	struct dt_node *mem;
-	char *name;
-	size_t namesz;
 	static u32 chip_id = 255;
 
-	/*
-	 * Find and return the node if it already exists.
-	 */
-	namesz = sizeof("memory@") + STR_MAX_CHARS(addr);
-	name = malloc(namesz);
-	if (!name)
-		return NULL;
-	snprintf(name, namesz, "memory@%llx", (long long)addr);
-	mem = dt_find_by_name(dt_root, name);
-	free(name);
+	mem = dt_find_by_name_addr(dt_root, "memory", addr);
 	if (mem)
 		return mem;
 
-- 
1.8.3.1



More information about the Skiboot mailing list