summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2024-08-22 23:16:57 +0200
committerFelix Held <felix-coreboot@felixheld.de>2024-08-29 13:58:21 +0000
commitaa75ee1a71719160608611f1ea81a399ef0d875d (patch)
tree8e92b24bda9220320bf2ddd5f24ab35e1a59b00b /src/lib
parent86dadcd52aaf0db59d4f770a6ff8527ed681e86e (diff)
cbmem.h: Change return type of cbmem_get_region
The underlying IMD function already returns an integer which indicates success or failure. This removes the need to have initialized variables that need to be checked for NULL later. In some cases this actually adds the appropriate check for returned values. Dying is appropriate if cbmem is not found as it is essential to the bootflow. Change-Id: Ib3e09a75380faf9f533601368993261f042422ef Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/84039 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fit_payload.c7
-rw-r--r--src/lib/imd_cbmem.c13
2 files changed, 11 insertions, 9 deletions
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index 21bc4e87ed..aea1ba75e9 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -110,8 +110,8 @@ static void add_cb_fdt_data(struct device_tree *tree)
{
u32 addr_cells = 1, size_cells = 1;
u64 reg_addrs[2], reg_sizes[2];
- void *baseptr = NULL;
- size_t size = 0;
+ void *baseptr;
+ size_t size;
static const char *firmware_path[] = {"firmware", NULL};
struct device_tree_node *firmware_node = dt_find_node(tree->root,
@@ -140,8 +140,7 @@ static void add_cb_fdt_data(struct device_tree *tree)
/* Second is the CBMEM area (which usually includes the coreboot
table). */
- cbmem_get_region(&baseptr, &size);
- if (!baseptr || size == 0) {
+ if (cbmem_get_region(&baseptr, &size)) {
printk(BIOS_WARNING, "FIT: CBMEM pointer/size not found!\n");
return;
}
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index a88cf98d6c..2fc54bfff7 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -193,16 +193,19 @@ void *cbmem_entry_start(const struct cbmem_entry *entry)
void cbmem_add_bootmem(void)
{
- void *baseptr = NULL;
- size_t size = 0;
+ void *baseptr;
+ size_t size;
- cbmem_get_region(&baseptr, &size);
+ if (cbmem_get_region(&baseptr, &size)) {
+ printk(BIOS_ERR, "CBMEM pointer/size not found!\n");
+ return;
+ }
bootmem_add_range((uintptr_t)baseptr, size, BM_MEM_TABLE);
}
-void cbmem_get_region(void **baseptr, size_t *size)
+int cbmem_get_region(void **baseptr, size_t *size)
{
- imd_region_used(&imd, baseptr, size);
+ return imd_region_used(&imd, baseptr, size);
}
#if ENV_PAYLOAD_LOADER || (CONFIG(EARLY_CBMEM_LIST) && ENV_HAS_CBMEM)