[Skiboot] [PATCH 2/2] hdata/vpd: Improve vpd node find logic

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Oct 5 20:10:24 AEDT 2017


Use dt_find_by_name_addr() instead of dt_find_by_name(). That way we
can avoid unnecessary memory allocation/cleanup.

CC: Ananth N Mavinakayanahalli <ananth at linux.vnet.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hdata/vpd.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/hdata/vpd.c b/hdata/vpd.c
index c24ede8..82a8ae4 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -429,8 +429,6 @@ struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
 	const void *fruvpd;
 	const char *name;
 	uint64_t addr;
-	char *lname;
-	int len;
 
 	fru_id = HDIF_get_idata(hdr, indx_fru, &fru_id_sz);
 	if (!fru_id)
@@ -455,18 +453,8 @@ struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
 
 	name = vpd_map_name(entry->fru_id);
 	addr = (uint64_t)be16_to_cpu(entry->rsrc_id);
-	len = strlen(name) + STR_MAX_CHARS(addr) + 2;
-	lname = zalloc(len);
-	if (!lname) {
-		prerror("VPD: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	snprintf(lname, len, "%s@%llx", name, (long long)addr);
-
 	/* Get the node already created */
-	node = dt_find_by_name(dt_vpd, lname);
-	free(lname);
+	node = dt_find_by_name_addr(dt_vpd, name, addr);
 	/*
 	 * It is unlikely that node not found because vpd nodes have the
 	 * corresponding slca entry which we would have used to populate the vpd
-- 
2.9.3



More information about the Skiboot mailing list