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

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Sat Oct 7 04:31:41 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 | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/hdata/vpd.c b/hdata/vpd.c
index b647a13..17ae7fe 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -433,8 +433,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)
@@ -453,19 +451,9 @@ struct dt_node *dt_add_vpd_node(const struct HDIF_common_hdr *hdr,
 		return NULL;
 
 	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);
-
+	addr = be16_to_cpu(entry->rsrc_id);
 	/* 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