]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: simplify find_obj
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 26 Nov 2017 13:05:16 +0000 (14:05 +0100)
committerAlexander Graf <agraf@suse.de>
Fri, 1 Dec 2017 12:37:20 +0000 (13:37 +0100)
Use function efi_search_protocol().

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_device_path.c

index 9027ae8efb7b8eae89f3bbe1d88ca1bac19165ac..b4e2f933cb602113af249c3e9d7aa92b5981440b 100644 (file)
@@ -128,32 +128,27 @@ static struct efi_object *find_obj(struct efi_device_path *dp, bool short_path,
        struct efi_object *efiobj;
 
        list_for_each_entry(efiobj, &efi_obj_list, link) {
-               int i;
-
-               for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
-                       struct efi_handler *handler = &efiobj->protocols[i];
-                       struct efi_device_path *obj_dp;
-
-                       if (!handler->guid)
-                               break;
-
-                       if (guidcmp(handler->guid, &efi_guid_device_path))
-                               continue;
-
-                       obj_dp = handler->protocol_interface;
-
-                       do {
-                               if (efi_dp_match(dp, obj_dp) == 0) {
-                                       if (rem) {
-                                               *rem = ((void *)dp) +
-                                                       efi_dp_size(obj_dp);
-                                       }
-                                       return efiobj;
+               struct efi_handler *handler;
+               struct efi_device_path *obj_dp;
+               efi_status_t ret;
+
+               ret = efi_search_protocol(efiobj->handle,
+                                         &efi_guid_device_path, &handler);
+               if (ret != EFI_SUCCESS)
+                       continue;
+               obj_dp = handler->protocol_interface;
+
+               do {
+                       if (efi_dp_match(dp, obj_dp) == 0) {
+                               if (rem) {
+                                       *rem = ((void *)dp) +
+                                               efi_dp_size(obj_dp);
                                }
+                               return efiobj;
+                       }
 
-                               obj_dp = shorten_path(efi_dp_next(obj_dp));
-                       } while (short_path && obj_dp);
-               }
+                       obj_dp = shorten_path(efi_dp_next(obj_dp));
+               } while (short_path && obj_dp);
        }
 
        return NULL;