]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: simplify efi_uninstall_protocol_interface
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 26 Oct 2017 17:25:56 +0000 (19:25 +0200)
committerAlexander Graf <agraf@suse.de>
Fri, 1 Dec 2017 12:22:56 +0000 (13:22 +0100)
Use function efi_search_obj, efi_search_protocol and
efi_remove_protocol to simplify the coding.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_boottime.c

index ff1f23356ef425b2b20f6a804167327ff8bbcc86..f32ddd50227615672cd82579df4925d35787017a 100644 (file)
@@ -906,9 +906,8 @@ static efi_status_t EFIAPI efi_uninstall_protocol_interface(
                                void *handle, const efi_guid_t *protocol,
                                void *protocol_interface)
 {
-       struct list_head *lhandle;
-       int i;
-       efi_status_t r = EFI_NOT_FOUND;
+       struct efi_handler *handler;
+       efi_status_t r;
 
        EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface);
 
@@ -917,31 +916,16 @@ static efi_status_t EFIAPI efi_uninstall_protocol_interface(
                goto out;
        }
 
-       list_for_each(lhandle, &efi_obj_list) {
-               struct efi_object *efiobj;
-               efiobj = list_entry(lhandle, struct efi_object, link);
-
-               if (efiobj->handle != handle)
-                       continue;
-
-               for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
-                       struct efi_handler *handler = &efiobj->protocols[i];
-                       const efi_guid_t *hprotocol = handler->guid;
-
-                       if (!hprotocol)
-                               continue;
-                       if (!guidcmp(hprotocol, protocol)) {
-                               if (handler->protocol_interface) {
-                                       r = EFI_ACCESS_DENIED;
-                               } else {
-                                       handler->guid = 0;
-                                       r = EFI_SUCCESS;
-                               }
-                               goto out;
-                       }
-               }
+       /* Find the protocol on the handle */
+       r = efi_search_protocol(handle, protocol, &handler);
+       if (r != EFI_SUCCESS)
+               goto out;
+       if (handler->protocol_interface) {
+               /* TODO disconnect controllers */
+               r =  EFI_ACCESS_DENIED;
+       } else {
+               r = efi_remove_protocol(handle, protocol, protocol_interface);
        }
-
 out:
        return EFI_EXIT(r);
 }