aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/samsung/lumpy/mainboard.c
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-06-28 17:18:06 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-07-01 07:37:21 +0000
commitd62a5012d6e5904279eb56507bc2a021d2acce77 (patch)
tree2b8a4eb40ed8842ca8f237501182a3684931ac2a /src/mainboard/samsung/lumpy/mainboard.c
parentca01baa065e25242945bdfa8631694a6e903f17f (diff)
SMBIOS: Introduce `smbios_carve_table` function
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 <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/55907 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Diffstat (limited to 'src/mainboard/samsung/lumpy/mainboard.c')
-rw-r--r--src/mainboard/samsung/lumpy/mainboard.c11
1 files changed, 4 insertions, 7 deletions
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;