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/drivers/elog/elog.c | 2 +- src/drivers/wifi/generic/smbios.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index 48b9dc365f..97555bc3f2 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -626,7 +626,7 @@ int elog_smbios_write_type15(unsigned long *current, int handle) t->log_type_descriptors = 0; t->log_type_descriptor_length = 2; - const int len = sizeof(*t); + const int len = smbios_full_table_len(&t->header, t->eos); *current += len; return len; } diff --git a/src/drivers/wifi/generic/smbios.c b/src/drivers/wifi/generic/smbios.c index e8936be386..7c697ad68f 100644 --- a/src/drivers/wifi/generic/smbios.c +++ b/src/drivers/wifi/generic/smbios.c @@ -28,7 +28,7 @@ static int smbios_write_intel_wifi(struct device *dev, int *handle, unsigned lon /* Intel wifi driver expects this string to be in the table 0x85. */ t->str = smbios_add_string(t->eos, "KHOIHGIUCCHHII"); - 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