util/sconfig: Move chip instance id assignment to emit_chips()
This change moves the assignment of id for chip instance from
new_chip_instance() to emit_chips(). This is similar to the previous
change for moving dev id assignment to happen much later.
This ensures that the same ID gets assigned to a chip when adding
support for device trees which makes it easier to compare static.c
files.
BUG=b:155549176
Change-Id: I3efa9af5ed91123675be42bce1cb389bad19cb62
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41006
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index 27fca44..951ad6d 100644
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -30,12 +30,6 @@
*/
static struct chip chip_header;
-/*
- * This is intentionally shared between chip and device structure ids because it
- * is easier to track the order of parsing for chip and device.
- */
-static int count = 0;
-
typedef enum {
UNSLASH,
SPLIT_1ST,
@@ -336,7 +330,6 @@
struct chip *chip = get_chip(path);
struct chip_instance *instance = S_ALLOC(sizeof(*instance));
- instance->id = ++count;
instance->chip = chip;
instance->next = chip->instance;
chip->instance = instance;
@@ -987,6 +980,7 @@
{
struct chip *chip = chip_header.next;
struct chip_instance *instance;
+ int chip_id;
emit_chip_headers(fil, chip);
@@ -996,8 +990,10 @@
if (!chip->chiph_exists)
continue;
+ chip_id = 1;
instance = chip->instance;
while (instance) {
+ instance->id = chip_id++;
emit_chip_instance(fil, instance);
instance = instance->next;
}