From d62a5012d6e5904279eb56507bc2a021d2acce77 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 28 Jun 2021 17:18:06 +0200 Subject: SMBIOS: Introduce `smbios_carve_table` function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Factor out some boilerplate code into a helper `smbios_carve_table` function, which zeroes out the table memory and fills in the header fields common to all tables. Change-Id: Iece2f64f9151d3c79813f6264dfb3a92d98c2035 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/55907 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Michał Żygowski --- src/mainboard/samsung/lumpy/mainboard.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/mainboard/samsung/lumpy/mainboard.c') diff --git a/src/mainboard/samsung/lumpy/mainboard.c b/src/mainboard/samsung/lumpy/mainboard.c index c2899b8e25..8b76a50239 100644 --- a/src/mainboard/samsung/lumpy/mainboard.c +++ b/src/mainboard/samsung/lumpy/mainboard.c @@ -28,13 +28,10 @@ static void mainboard_init(struct device *dev) static int lumpy_smbios_type41_irq(int *handle, unsigned long *current, const char *name, u8 irq, u8 addr) { - struct smbios_type41 *t = (struct smbios_type41 *)*current; - int len = sizeof(*t); + struct smbios_type41 *t = smbios_carve_table(*current, + SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION, + sizeof(*t), *handle); - memset(t, 0, sizeof(*t)); - t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION; - t->handle = *handle; - t->length = len - 2; t->reference_designation = smbios_add_string(t->eos, name); t->device_type = SMBIOS_DEVICE_TYPE_OTHER; t->device_status = 1; @@ -44,7 +41,7 @@ static int lumpy_smbios_type41_irq(int *handle, unsigned long *current, t->function_number = 0; t->device_number = 0; - len = t->length + smbios_string_table_len(t->eos); + const int len = t->length + smbios_string_table_len(t->eos); *current += len; *handle += 1; return len; -- cgit v1.2.3