diff mbox

platforms/astbmc: Fix the PCI slot location code

Message ID 1466403901-19153-1-git-send-email-gwshan@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Gavin Shan June 20, 2016, 6:25 a.m. UTC
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@russell.cc>
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 platforms/astbmc/slots.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Russell Currey June 20, 2016, 6:54 a.m. UTC | #1
On Mon, 2016-06-20 at 16:25 +1000, Gavin Shan wrote:
> 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@russell.cc>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---

Tested-by: Russell Currey <ruscur@russell.cc>
Stewart Smith June 21, 2016, 4:43 a.m. UTC | #2
Gavin Shan <gwshan@linux.vnet.ibm.com> writes:
> 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@russell.cc>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>

Thanks, pushed to master as of a28352d (after realising I should have
added a Fixes: )
diff mbox

Patch

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);