[Skiboot] [PATCH] platforms/astbmc: Fix the PCI slot location code

Gavin Shan gwshan at linux.vnet.ibm.com
Mon Jun 20 16:25:01 AEST 2016


After commit aa928bfbd891 ("platforms/astbmc: Support PCI slot")
is merged, we have the assumption that PHB's base location code
is always valid. It's not true on openPower platforms, including
Garrison. It causes the PCI slot location code isn't exposed via
device-tree.

This fixes the above issue. The PCI slot location code contains
the label only if PHB's base location code is invalid.

Reported-by: Russell Currey <ruscur at russell.cc>
Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 platforms/astbmc/slots.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/platforms/astbmc/slots.c b/platforms/astbmc/slots.c
index 7ece836..36547e1 100644
--- a/platforms/astbmc/slots.c
+++ b/platforms/astbmc/slots.c
@@ -84,17 +84,22 @@ static void add_slot_properties(struct pci_slot *slot,
 	size_t base_loc_code_len, slot_label_len;
 	char loc_code[LOC_CODE_SIZE];
 
-	if (!np || !ent || !phb->base_loc_code)
+	if (!np || !ent)
 		return;
 
-	base_loc_code_len = strlen(phb->base_loc_code);
+	base_loc_code_len = phb->base_loc_code ? strlen(phb->base_loc_code) : 0;
 	slot_label_len = strlen(ent->name);
 	if ((base_loc_code_len + slot_label_len + 1) >= LOC_CODE_SIZE)
 		return;
 
 	/* Location code */
-	strcpy(loc_code, phb->base_loc_code);
-	strcat(loc_code, "-");
+	if (phb->base_loc_code) {
+		strcpy(loc_code, phb->base_loc_code);
+		strcat(loc_code, "-");
+	} else {
+		loc_code[0] = '\0';
+	}
+
 	strcat(loc_code, ent->name);
 	dt_add_property(np, "ibm,slot-location-code",
 			loc_code, strlen(loc_code) + 1);
-- 
2.1.0



More information about the Skiboot mailing list