[Skiboot] [PATCH] PCI: use define for wanting dynamic PHB id for pci_register_phb

Stewart Smith stewart at linux.vnet.ibm.com
Tue Nov 17 15:47:47 AEDT 2015


No functional change, but static analysis showed up the oddity of
something that is generally unsigned (opal_id) having a signed
value assigned to it.

Took the opportunity to use a define to increase readability.

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 core/pci.c      | 2 +-
 hw/npu.c        | 2 +-
 hw/p5ioc2-phb.c | 2 +-
 hw/p7ioc-phb.c  | 2 +-
 include/pci.h   | 1 +
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index e584da82024e..03d5a35b3a1c 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -795,7 +795,7 @@ static void pci_scan_phb(void *data)
 int64_t pci_register_phb(struct phb *phb, int opal_id)
 {
 	/* The user didn't specify an opal_id, allocate one */
-	if (opal_id < 0) {
+	if (opal_id == OPAL_DYNAMIC_PHB_ID) {
 		/* This is called at init time in non-concurrent way, so no lock needed */
 		for (opal_id = 0; opal_id < ARRAY_SIZE(phbs); opal_id++)
 			if (!phbs[opal_id])
diff --git a/hw/npu.c b/hw/npu.c
index 3649728b8726..f0be9fc76e95 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -1692,7 +1692,7 @@ static void npu_create_phb(struct dt_node *dn)
 	npu_add_phb_properties(p);
 
 	/* Register PHB */
-	pci_register_phb(&p->phb, -1);
+	pci_register_phb(&p->phb, OPAL_DYNAMIC_PHB_ID);
 
 	/* Initialize IODA cache */
 	npu_ioda_init(p);
diff --git a/hw/p5ioc2-phb.c b/hw/p5ioc2-phb.c
index 1c9dbb6a8461..70a1a0925d1f 100644
--- a/hw/p5ioc2-phb.c
+++ b/hw/p5ioc2-phb.c
@@ -1197,7 +1197,7 @@ void p5ioc2_phb_setup(struct p5ioc2 *ioc, struct p5ioc2_phb *p,
 	/* We register the PHB before we initialize it so we
 	 * get a useful OPAL ID for it
 	 */
-	pci_register_phb(&p->phb, -1);
+	pci_register_phb(&p->phb, OPAL_DYNAMIC_PHB_ID);
 
 	/* Platform additional setup */
 	if (platform.pci_setup_phb)
diff --git a/hw/p7ioc-phb.c b/hw/p7ioc-phb.c
index 66c166f7a74f..97e4885cbe31 100644
--- a/hw/p7ioc-phb.c
+++ b/hw/p7ioc-phb.c
@@ -2929,7 +2929,7 @@ void p7ioc_phb_setup(struct p7ioc *ioc, uint8_t index)
 	/* We register the PHB before we initialize it so we
 	 * get a useful OPAL ID for it
 	 */
-	pci_register_phb(&p->phb, -1);
+	pci_register_phb(&p->phb, OPAL_DYNAMIC_PHB_ID);
 
 	/* Platform additional setup */
 	if (platform.pci_setup_phb)
diff --git a/include/pci.h b/include/pci.h
index 52579ad10a30..4640ddae6fb5 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -531,6 +531,7 @@ extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
 					uint32_t flags, pci_cfg_reg_func func);
 
 /* Manage PHBs */
+#define OPAL_DYNAMIC_PHB_ID (~0)
 extern int64_t pci_register_phb(struct phb *phb, int opal_id);
 extern int64_t pci_unregister_phb(struct phb *phb);
 extern struct phb *pci_get_phb(uint64_t phb_id);
-- 
2.1.4



More information about the Skiboot mailing list