From a37701afa373dbe35f307614779f43183fd53151 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 28 Jun 2021 17:36:53 +0200 Subject: SMBIOS: Introduce `smbios_full_table_len` function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce the `smbios_full_table_len` function to consolidate table length calculation. The case where the length of a table equals the length of the structure happens when a table has no strings. Change-Id: Ibc60075e82eb66b5d0b7132b16da000b153413f9 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/55909 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Michał Żygowski --- src/mainboard/emulation/qemu-i440fx/northbridge.c | 4 ++-- src/mainboard/pcengines/apu1/mainboard.c | 4 ++-- src/mainboard/pcengines/apu2/mainboard.c | 4 ++-- src/mainboard/samsung/lumpy/mainboard.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mainboard') diff --git a/src/mainboard/emulation/qemu-i440fx/northbridge.c b/src/mainboard/emulation/qemu-i440fx/northbridge.c index 2f70f98f93..68410b03e7 100644 --- a/src/mainboard/emulation/qemu-i440fx/northbridge.c +++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c @@ -173,7 +173,7 @@ static int qemu_get_smbios_data16(int handle, unsigned long *current) t->memory_error_correction = MEMORY_ARRAY_ECC_NONE; t->maximum_capacity = qemu_get_memory_size(); - const int len = sizeof(*t); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } @@ -195,7 +195,7 @@ static int qemu_get_smbios_data17(int handle, int parent_handle, unsigned long * t->clock_speed = 200; t->manufacturer = smbios_add_string(t->eos, CONFIG_MAINBOARD_VENDOR); - const int len = t->length + smbios_string_table_len(t->eos); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c index 87bab71651..f7b34f0c3c 100644 --- a/src/mainboard/pcengines/apu1/mainboard.c +++ b/src/mainboard/pcengines/apu1/mainboard.c @@ -180,7 +180,7 @@ static int mainboard_smbios_type16(DMI_INFO *agesa_dmi, int *handle, unsigned lo t->memory_error_information_handle = 0xfffe; t->number_of_memory_devices = 1; - const int len = sizeof(*t); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } @@ -212,7 +212,7 @@ static int mainboard_smbios_type17(DMI_INFO *agesa_dmi, int *handle, unsigned lo t->minimum_voltage = 1500; /* From SPD: 1.5V */ t->maximum_voltage = 1500; - const int len = t->length + smbios_string_table_len(t->eos); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c index cab89a289b..9371ee9290 100644 --- a/src/mainboard/pcengines/apu2/mainboard.c +++ b/src/mainboard/pcengines/apu2/mainboard.c @@ -162,7 +162,7 @@ static int mainboard_smbios_type16(DMI_INFO *agesa_dmi, int *handle, t->memory_error_information_handle = 0xfffe; t->number_of_memory_devices = 1; - const int len = sizeof(*t); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } @@ -198,7 +198,7 @@ static int mainboard_smbios_type17(DMI_INFO *agesa_dmi, int *handle, t->minimum_voltage = 1500; /* From SPD: 1.5V */ t->maximum_voltage = 1500; - const int len = t->length + smbios_string_table_len(t->eos); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } diff --git a/src/mainboard/samsung/lumpy/mainboard.c b/src/mainboard/samsung/lumpy/mainboard.c index 8b76a50239..d804b2b974 100644 --- a/src/mainboard/samsung/lumpy/mainboard.c +++ b/src/mainboard/samsung/lumpy/mainboard.c @@ -41,7 +41,7 @@ static int lumpy_smbios_type41_irq(int *handle, unsigned long *current, t->function_number = 0; t->device_number = 0; - const int len = t->length + smbios_string_table_len(t->eos); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; *handle += 1; return len; -- cgit v1.2.3