diff mbox series

[U-Boot,v2,02/16] efi: Move the init check inside efi_init_obj_list()

Message ID 20171204212832.130100-3-sjg@chromium.org
State Superseded
Delegated to: Alexander Graf
Headers show
Series efi: Enable basic sandbox support for EFI loader | expand

Commit Message

Simon Glass Dec. 4, 2017, 9:28 p.m. UTC
Rather than having the caller check this variable and the callee set it,
move all access to the variable inside the function. This reduces the
logic needed to call efi_init_obj_list().

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

Changes in v2: None

 cmd/bootefi.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Heinrich Schuchardt Dec. 4, 2017, 10:23 p.m. UTC | #1
On 12/04/2017 10:28 PM, Simon Glass wrote:
> Rather than having the caller check this variable and the callee set it,
> move all access to the variable inside the function. This reduces the
> logic needed to call efi_init_obj_list().
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> 
> Changes in v2: None
> 
>   cmd/bootefi.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 478bc116e2..17b26e6f4e 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -28,6 +28,8 @@ static struct efi_device_path *bootefi_device_path;
>   /* Initialize and populate EFI object list */
>   static void efi_init_obj_list(void)
>   {
> +	if (efi_obj_list_initalized)
> +		return;
>   	efi_obj_list_initalized = 1;
>   
>   	efi_console_register();
> @@ -208,6 +210,9 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt,
>   	env_set("efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_OsIndicationsSupported",
>   		"{ro,boot}(blob)0000000000000000");
>   
> +	/* Initialize and populate EFI object list */
> +	efi_init_obj_list();

If you add it here where do you remove the old call? We do not want to 
do the assignments twice.

> +
>   	/* Call our payload! */
>   	debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
>   
> @@ -310,6 +315,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   		/* Initialize and populate EFI object list */
>   		if (!efi_obj_list_initalized)
>   			efi_init_obj_list();
> +		loaded_image_info.device_handle = bootefi_device_path;
> +		loaded_image_info.file_path = bootefi_image_path;

Same.

Best regards

Heinrich

>   		return efi_selftest(&loaded_image_info, &systab);
>   	} else
>   #endif
>
diff mbox series

Patch

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 478bc116e2..17b26e6f4e 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -28,6 +28,8 @@  static struct efi_device_path *bootefi_device_path;
 /* Initialize and populate EFI object list */
 static void efi_init_obj_list(void)
 {
+	if (efi_obj_list_initalized)
+		return;
 	efi_obj_list_initalized = 1;
 
 	efi_console_register();
@@ -208,6 +210,9 @@  static unsigned long do_bootefi_exec(void *efi, void *fdt,
 	env_set("efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_OsIndicationsSupported",
 		"{ro,boot}(blob)0000000000000000");
 
+	/* Initialize and populate EFI object list */
+	efi_init_obj_list();
+
 	/* Call our payload! */
 	debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
 
@@ -310,6 +315,8 @@  static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		/* Initialize and populate EFI object list */
 		if (!efi_obj_list_initalized)
 			efi_init_obj_list();
+		loaded_image_info.device_handle = bootefi_device_path;
+		loaded_image_info.file_path = bootefi_image_path;
 		return efi_selftest(&loaded_image_info, &systab);
 	} else
 #endif