[Skiboot] [PATCH 3/3] core/vpd: rename vpd to vpd_lid

Oliver O'Halloran oohall at gmail.com
Mon Sep 5 12:07:49 AEST 2016


This file contains several helper functions which also take an argument
named "vpd". Even at the best of times, the VPD parsing code is a soup
of confusing terminology so lets not make a bad situation worse. This
patch renames vpd to vpd_lid and vpd_size to vpd_lid_size to clarify the
situation.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 core/vpd.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/core/vpd.c b/core/vpd.c
index 050bd42f7482..5b501e9982f8 100644
--- a/core/vpd.c
+++ b/core/vpd.c
@@ -118,8 +118,8 @@ const void *vpd_find(const void *vpd, size_t vpd_size,
 	return p;
 }
 
-static void *vpd;
-static size_t vpd_size;
+static void *vpd_lid;
+static size_t vpd_lid_size;
 static uint32_t vpd_lid_no;
 
 /* Helper to load a VPD LID. Pass a ptr to the corresponding LX keyword */
@@ -146,9 +146,9 @@ static void *vpd_lid_preload(const uint8_t *lx)
 	 * I've seen so far are much smaller.
 	 */
 #define VPD_LID_MAX_SIZE	0x4000
-	vpd = malloc(VPD_LID_MAX_SIZE);
+	vpd_lid = malloc(VPD_LID_MAX_SIZE);
 
-	if (!vpd) {
+	if (!vpd_lid) {
 		prerror("VPD: Failed to allocate memory for LID\n");
 		return NULL;
 	}
@@ -157,18 +157,18 @@ static void *vpd_lid_preload(const uint8_t *lx)
 	vpd_lid_no = fsp_adjust_lid_side(vpd_lid_no);
 	printf("VPD: Trying to load VPD LID 0x%08x...\n", vpd_lid_no);
 
-	vpd_size = VPD_LID_MAX_SIZE;
+	vpd_lid_size = VPD_LID_MAX_SIZE;
 
 	/* Load it from the FSP */
-	rc = fsp_preload_lid(vpd_lid_no, vpd, &vpd_size);
+	rc = fsp_preload_lid(vpd_lid_no, vpd_lid, &vpd_lid_size);
 	if (rc) {
 		prerror("VPD: Error %d loading VPD LID\n", rc);
 		goto fail;
 	}
 
-	return vpd;
+	return vpd_lid;
  fail:
-	free(vpd);
+	free(vpd_lid);
 	return NULL;
 }
 
@@ -189,7 +189,8 @@ void vpd_iohub_load(struct dt_node *hub_node)
 	lxrn = p[0];
         lx = (const char *)&p[1];
 
-	if (!vpd || !vpd_lid_no) {
+	/* verify the lid preload has started */
+	if (!vpd_lid || !vpd_lid_no) {
 		prlog(PR_WARNING, "VPD: WARNING: Unable to iohub VPD lid");
 		return;
 	}
@@ -205,7 +206,7 @@ void vpd_iohub_load(struct dt_node *hub_node)
 	else
 		memcpy(record, "VINI", 4);
 
-	valid_lx = vpd_find(vpd, vpd_size, record, "LX", &lx_size);
+	valid_lx = vpd_find(vpd_lid, vpd_lid_size, record, "LX", &lx_size);
 	if (!valid_lx || lx_size != 8) {
 		prerror("VPD: Cannot find validation LX record\n");
 		goto fail;
@@ -215,15 +216,15 @@ void vpd_iohub_load(struct dt_node *hub_node)
 		goto fail;
 	}
 
-	printf("VPD: Loaded %zu bytes\n", vpd_size);
+	printf("VPD: Loaded %zu bytes\n", vpd_lid_size);
 
-	dt_add_property(hub_node, "ibm,io-vpd", vpd, vpd_size);
-	free(vpd);
+	dt_add_property(hub_node, "ibm,io-vpd", vpd_lid, vpd_lid_size);
+	free(vpd_lid);
 	return;
 
 fail:
-	free(vpd);
-	vpd = NULL;
+	free(vpd_lid);
+	vpd_lid = NULL;
 	prerror("VPD: Failed to load VPD LID\n");
 	return;
 }
@@ -239,5 +240,5 @@ void vpd_preload(struct dt_node *hub_node)
 
 	lxr = (const char *)&p[1];
 
-	vpd = vpd_lid_preload(lxr);
+	vpd_lid = vpd_lid_preload(lxr);
 }
-- 
2.5.5



More information about the Skiboot mailing list