diff mbox

[U-Boot,05/23] efi_loader: rework efi_search_obj

Message ID 20170826225110.7381-6-xypron.glpk@gmx.de
State Superseded, archived
Delegated to: Alexander Graf
Headers show

Commit Message

Heinrich Schuchardt Aug. 26, 2017, 10:51 p.m. UTC
EFI_HANDLEs are used both in boottime and in runtime services.
efi_search_obj is a function that can be used to validate
handles. So let's make it accessible via efi_loader.h.

We can simplify the coding using list_for_each_entry.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 include/efi_loader.h          | 2 ++
 lib/efi_loader/efi_boottime.c | 8 +++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Simon Glass Aug. 31, 2017, 12:51 p.m. UTC | #1
On 27 August 2017 at 06:51, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> EFI_HANDLEs are used both in boottime and in runtime services.
> efi_search_obj is a function that can be used to validate
> handles. So let's make it accessible via efi_loader.h.
>
> We can simplify the coding using list_for_each_entry.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  include/efi_loader.h          | 2 ++
>  lib/efi_loader/efi_boottime.c | 8 +++-----
>  2 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/include/efi_loader.h b/include/efi_loader.h
index e8fb4fbb0a..193fca24ce 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -167,6 +167,8 @@  void efi_restore_gd(void);
 void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
 /* Call this to set the current device name */
 void efi_set_bootdev(const char *dev, const char *devnr, const char *path);
+/* Call this to validate a handle and find the EFI object for it */
+struct efi_object *efi_search_obj(void *handle);
 /* Call this to create an event */
 efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,
 			      void (EFIAPI *notify_function) (
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 570a5ea186..b643d299b9 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -822,13 +822,11 @@  static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
 	panic("EFI application exited");
 }
 
-static struct efi_object *efi_search_obj(void *handle)
+struct efi_object *efi_search_obj(void *handle)
 {
-	struct list_head *lhandle;
+	struct efi_object *efiobj;
 
-	list_for_each(lhandle, &efi_obj_list) {
-		struct efi_object *efiobj;
-		efiobj = list_entry(lhandle, struct efi_object, link);
+	list_for_each_entry(efiobj, &efi_obj_list, link) {
 		if (efiobj->handle == handle)
 			return efiobj;
 	}