diff mbox series

[v3,2/2] hdata: Make sure reserved node name starts with "ibm, "

Message ID 20180907051655.5812-2-hegdevasant@linux.vnet.ibm.com
State Accepted
Headers show
Series [v3,1/2] hdata: Cleanup get_hb_reserved_mem | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/make_check success Test make_check on branch master

Commit Message

Vasant Hegde Sept. 7, 2018, 5:16 a.m. UTC
HDAT does not provide consistent label format for reserved memory label.
Few starts with "ibm," while few other starts with component name.

Lets make sure all the reserved node name starts with "ibm,".

Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hdata/memory.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/hdata/memory.c b/hdata/memory.c
index d9c9ddda9..e7566ef5a 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -565,6 +565,8 @@  static struct dt_node *dt_hb_reserves;
 
 static struct dt_node *add_hb_reserve_node(const char *name, u64 start, u64 end)
 {
+	/* label size + "ibm," + NULL */
+	char node_name[HB_RESERVE_MEM_LABEL_SIZE + 5] = { 0 };
 	struct dt_node *node, *hb;
 
 	if (!dt_hb_reserves) {
@@ -578,10 +580,15 @@  static struct dt_node *add_hb_reserve_node(const char *name, u64 start, u64 end)
 		dt_add_property_cells(dt_hb_reserves, "#address-cells", 2);
 	}
 
-	node = dt_new_addr(dt_hb_reserves, name, start);
+	/* Add "ibm," to reserved node name */
+	if (strncasecmp(name, "ibm", 3))
+		snprintf(node_name, 5, "ibm,");
+	strcat(node_name, name);
+
+	node = dt_new_addr(dt_hb_reserves, node_name, start);
 	if (!node) {
 		prerror("Unable to create node for %s@%llx\n",
-			name, (unsigned long long) start);
+			node_name, (unsigned long long) start);
 		return NULL;
 	}