[U-Boot,v12,6/6] efi: Rename bootefi_test_finish() to bootefi_run_finish()

Message ID 20181106225744.139945-7-sjg@chromium.org
State New
Delegated to: Alexander Graf
Headers show
Series
  • efi_loader: Code refactoring and improvement
Related show

Commit Message

Simon Glass Nov. 6, 2018, 10:57 p.m.
This function can be used from do_bootefi_exec() so that we use mostly the
same code for a normal EFI application and an EFI test.

Rename the function and use it in both places.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v12: None
Changes in v11:
- Drop patches previously applied

Changes in v9: None
Changes in v7:
- Drop patch "efi: Init the 'rows' and 'cols' variables"
- Drop patches previous applied

Changes in v5:
- Rebase to master

Changes in v4:
- Rebase to master

Changes in v3:
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()

 cmd/bootefi.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

Patch

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 779c1f63fa8..7a077995dc5 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -351,6 +351,20 @@  static efi_status_t bootefi_run_prepare(const char *load_options_path,
 	return 0;
 }
 
+/**
+ * bootefi_run_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_run_finish(struct efi_loaded_image *image,
+			       struct efi_loaded_image_obj *obj)
+{
+	efi_restore_gd();
+	free(image->load_options);
+	efi_delete_handle(&obj->parent);
+}
+
 /**
  * do_bootefi_exec() - execute EFI binary
  *
@@ -468,8 +482,7 @@  static efi_status_t do_bootefi_exec(void *efi,
 
 exit:
 	/* image has returned, loaded-image obj goes *poof*: */
-	if (obj)
-		efi_delete_handle(&obj->parent);
+	bootefi_run_finish(image, obj);
 	if (mem_handle)
 		efi_delete_handle(mem_handle);
 
@@ -507,20 +520,6 @@  static efi_status_t bootefi_test_prepare(struct efi_loaded_image **imagep,
 	return bootefi_run_prepare(load_options_path, bootefi_device_path,
 				   bootefi_image_path, imagep, objp);
 }
-
-/**
- * bootefi_test_finish() - finish up after running an EFI test
- *
- * @image: Pointer to a struct which holds the loaded image info
- * @obj: Pointer to a struct which holds the loaded image object
- */
-static void bootefi_test_finish(struct efi_loaded_image *image,
-				struct efi_loaded_image_obj *obj)
-{
-	efi_restore_gd();
-	free(image->load_options);
-	efi_delete_handle(&obj->parent);
-}
 #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
 
 static int do_bootefi_bootmgr_exec(void)
@@ -605,7 +604,7 @@  static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		/* Execute the test */
 		r = efi_selftest(obj, &systab);
-		bootefi_test_finish(image_prot, obj);
+		bootefi_run_finish(image_prot, obj);
 		return r != EFI_SUCCESS;
 	} else
 #endif