core/pci.c: cleanup pci_add_loc_code()
diff mbox series

Message ID 20200305142456.25797-1-klaus@linux.vnet.ibm.com
State Accepted
Headers show
Series
  • core/pci.c: cleanup pci_add_loc_code()
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (82aed17a5468aff6b600ee1694a10a60f942c018)

Commit Message

Klaus Heinrich Kiwi March 5, 2020, 2:24 p.m. UTC
Minor cleanups to add clarity after commit ab1b05d2
"PCI: create optional loc-code platform callback"

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
---
 core/pci.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

Comments

Oliver O'Halloran March 30, 2020, 6:34 a.m. UTC | #1
On Fri, Mar 6, 2020 at 1:25 AM Klaus Heinrich Kiwi
<klaus@linux.vnet.ibm.com> wrote:
>
> Minor cleanups to add clarity after commit ab1b05d2
> "PCI: create optional loc-code platform callback"
>
> Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>

Thanks, merged as of b8b1ebc15f1c3eb011491bd10965f64a6a5ba3ab

Patch
diff mbox series

diff --git a/core/pci.c b/core/pci.c
index d211207b..cc7353be 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1385,42 +1385,37 @@  void pci_std_swizzle_irq_map(struct dt_node *np,
 
 static void pci_add_loc_code(struct dt_node *np)
 {
-	struct dt_node *p = np->parent;
-	const char *blcode = NULL;
+	struct dt_node *p;
+	const char *lcode = NULL;
 
-	while (p) {
+	for (p = np->parent; p; p = p->parent) {
 		/* prefer slot-label by default */
-		blcode = dt_prop_get_def(p, "ibm,slot-label", NULL);
-		if (blcode)
+		lcode = dt_prop_get_def(p, "ibm,slot-label", NULL);
+		if (lcode)
 			break;
 
 		/* otherwise use the fully qualified location code */
-		blcode = dt_prop_get_def(p, "ibm,slot-location-code", NULL);
-		if (blcode)
+		lcode = dt_prop_get_def(p, "ibm,slot-location-code", NULL);
+		if (lcode)
 			break;
-
-		p = p->parent;
 	}
 
-	if (!blcode)
-		blcode = dt_prop_get_def(np, "ibm,slot-location-code", NULL);
+	if (!lcode)
+		lcode = dt_prop_get_def(np, "ibm,slot-location-code", NULL);
 
-	if (!blcode) {
+	if (!lcode) {
 		/* Fall back to finding a ibm,loc-code */
-		p = np->parent;
-
-		while (p) {
-			blcode = dt_prop_get_def(p, "ibm,loc-code", NULL);
-			if (blcode)
+		for (p = np->parent; p; p = p->parent) {
+			lcode = dt_prop_get_def(p, "ibm,loc-code", NULL);
+			if (lcode)
 				break;
-			p = p->parent;
 		}
 	}
 
-	if (!blcode)
+	if (!lcode)
 		return;
 
-	dt_add_property_string(np, "ibm,loc-code", blcode);
+	dt_add_property_string(np, "ibm,loc-code", lcode);
 }
 
 static void pci_print_summary_line(struct phb *phb, struct pci_device *pd,