[Skiboot] [PATCH 1/5] chip: Factor out chip inititialisation
Michael Ellerman
mpe at ellerman.id.au
Thu Jun 8 22:54:17 AEST 2017
Move the chip initialisation logic into a function, so we can call it from
elsewhere in future.
Only change to the logic is that we don't insert the chip into chips[] until
we've finished initialising it.
Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
---
core/chip.c | 50 +++++++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/core/chip.c b/core/chip.c
index 7765545e9938..3550804383dc 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -71,9 +71,35 @@ struct proc_chip *get_chip(uint32_t chip_id)
return chips[chip_id];
}
-void init_chips(void)
+static void init_chip(struct dt_node *dn)
{
struct proc_chip *chip;
+ uint32_t id;
+
+ id = dt_get_chip_id(dn);
+ assert(id < MAX_CHIPS);
+
+ chip = zalloc(sizeof(struct proc_chip));
+ assert(chip);
+
+ chip->id = id;
+ chip->devnode = dn;
+
+ chip->dbob_id = dt_prop_get_u32_def(dn, "ibm,dbob-id", 0xffffffff);
+ chip->pcid = dt_prop_get_u32_def(dn, "ibm,proc-chip-id", 0xffffffff);
+
+ if (dt_prop_get_u32_def(dn, "ibm,occ-functional-state", 0))
+ chip->occ_functional = true;
+ else
+ chip->occ_functional = false;
+
+ list_head_init(&chip->i2cms);
+
+ chips[id] = chip;
+}
+
+void init_chips(void)
+{
struct dt_node *xn;
/* Detect mambo chip */
@@ -106,24 +132,6 @@ void init_chips(void)
/* We walk the chips based on xscom nodes in the tree */
dt_for_each_compatible(dt_root, xn, "ibm,xscom") {
- uint32_t id = dt_get_chip_id(xn);
-
- assert(id < MAX_CHIPS);
-
- chip = zalloc(sizeof(struct proc_chip));
- assert(chip);
- chip->id = id;
- chip->devnode = xn;
- chips[id] = chip;
- chip->dbob_id = dt_prop_get_u32_def(xn, "ibm,dbob-id",
- 0xffffffff);
- chip->pcid = dt_prop_get_u32_def(xn, "ibm,proc-chip-id",
- 0xffffffff);
- if (dt_prop_get_u32_def(xn, "ibm,occ-functional-state", 0))
- chip->occ_functional = true;
- else
- chip->occ_functional = false;
-
- list_head_init(&chip->i2cms);
- };
+ init_chip(xn);
+ }
}
--
2.7.4
More information about the Skiboot
mailing list