From 9f681d2d7c48431d2d286d5ce7060bba924f4e37 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Sat, 2 May 2020 15:51:02 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41006 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- util/sconfig/main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 27fca44179..951ad6d219 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -30,12 +30,6 @@ extern int linenum; */ 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_instance *new_chip_instance(char *path) 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 @@ static void emit_chips(FILE *fil) { struct chip *chip = chip_header.next; struct chip_instance *instance; + int chip_id; emit_chip_headers(fil, chip); @@ -996,8 +990,10 @@ static void emit_chips(FILE *fil) 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; }