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>
This commit is contained in:
Furquan Shaikh 2020-05-02 15:51:02 -07:00
parent 4ebe953090
commit 9f681d2d7c
1 changed files with 3 additions and 7 deletions

View File

@ -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;
}