From d56d2a86edace2a0058a54c2d1a075b1211e2945 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Fri, 3 Sep 2021 16:55:25 +0200 Subject: [PATCH] util/sconfig: Extract handling of SMBIOS data Move the code that handles devices' SMBIOS data into a helper function. Change-Id: I4f36d6c6f26e79558d360d319d09b0b8426def0e Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/57369 Reviewed-by: Nico Huber Reviewed-by: Tim Wawrzynczak Tested-by: build bot (Jenkins) --- util/sconfig/main.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 9d791ef6c3..2b1feda95e 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -1108,6 +1108,29 @@ static void pass0(FILE *fil, FILE *head, struct device *ptr, struct device *next ptr->name); } +static void emit_smbios_data(FILE *fil, struct device *ptr) +{ + fprintf(fil, "#if !DEVTREE_EARLY\n"); + fprintf(fil, "#if CONFIG(GENERATE_SMBIOS_TABLES)\n"); + + /* SMBIOS types start at 1, if zero it hasn't been set */ + if (ptr->smbios_slot_type) + fprintf(fil, "\t.smbios_slot_type = %s,\n", + ptr->smbios_slot_type); + if (ptr->smbios_slot_data_width) + fprintf(fil, "\t.smbios_slot_data_width = %s,\n", + ptr->smbios_slot_data_width); + if (ptr->smbios_slot_designation) + fprintf(fil, "\t.smbios_slot_designation = \"%s\",\n", + ptr->smbios_slot_designation); + if (ptr->smbios_slot_length) + fprintf(fil, "\t.smbios_slot_length = %s,\n", + ptr->smbios_slot_length); + + fprintf(fil, "#endif\n"); + fprintf(fil, "#endif\n"); +} + static void emit_resources(FILE *fil, struct device *ptr) { if (ptr->res == NULL) @@ -1266,23 +1289,9 @@ static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next chip_ins->chip->name_underscore, chip_ins->id); if (next) fprintf(fil, "\t.next=&%s,\n", next->name); - fprintf(fil, "#if !DEVTREE_EARLY\n"); - fprintf(fil, "#if CONFIG(GENERATE_SMBIOS_TABLES)\n"); - /* SMBIOS types start at 1, if zero it hasn't been set */ - if (ptr->smbios_slot_type) - fprintf(fil, "\t.smbios_slot_type = %s,\n", - ptr->smbios_slot_type); - if (ptr->smbios_slot_data_width) - fprintf(fil, "\t.smbios_slot_data_width = %s,\n", - ptr->smbios_slot_data_width); - if (ptr->smbios_slot_designation) - fprintf(fil, "\t.smbios_slot_designation = \"%s\",\n", - ptr->smbios_slot_designation); - if (ptr->smbios_slot_length) - fprintf(fil, "\t.smbios_slot_length = %s,\n", - ptr->smbios_slot_length); - fprintf(fil, "#endif\n"); - fprintf(fil, "#endif\n"); + + emit_smbios_data(fil, ptr); + fprintf(fil, "};\n"); emit_resources(fil, ptr);