[PATCH 6/6] efi_loader: bootmgr: use get_var from efi_helper file
Ilias Apalodimas
ilias.apalodimas at linaro.org
Mon Dec 28 13:24:38 CET 2020
A few patches before we introduced a file which includes the get_var()
function defined in the efi bootmanager.
So let's replace it here and use the common function as much as we can.
Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---
lib/efi_loader/Makefile | 2 +-
lib/efi_loader/efi_bootmgr.c | 33 +--------------------------------
2 files changed, 2 insertions(+), 33 deletions(-)
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 793e5b7f8730..d21d57d5811e 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -21,7 +21,7 @@ targets += helloworld.o
endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
-obj-y += efi_bootmgr.o
+obj-y += efi_helper.o efi_bootmgr.o
obj-y += efi_boottime.o
obj-y += efi_console.o
obj-y += efi_device_path.o
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index ceca5c5b1bf3..a175842ae053 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -11,6 +11,7 @@
#include <charset.h>
#include <log.h>
#include <malloc.h>
+#include <efi_helper.h>
#include <efi_loader.h>
#include <efi_load_initrd.h>
#include <efi_variable.h>
@@ -166,38 +167,6 @@ unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data)
return size;
}
-/**
- * get_var() - get UEFI variable
- *
- * It is the caller's duty to free the returned buffer.
- *
- * @name: name of variable
- * @vendor: vendor GUID of variable
- * @size: size of allocated buffer
- * Return: buffer with variable data or NULL
- */
-static void *get_var(u16 *name, const efi_guid_t *vendor,
- efi_uintn_t *size)
-{
- efi_status_t ret;
- void *buf = NULL;
-
- *size = 0;
- ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
- if (ret == EFI_BUFFER_TOO_SMALL) {
- buf = malloc(*size);
- ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
- }
-
- if (ret != EFI_SUCCESS) {
- free(buf);
- *size = 0;
- return NULL;
- }
-
- return buf;
-}
-
/**
* try_load_entry() - try to load image for boot option
*
--
2.30.0.rc2
More information about the U-Boot
mailing list