Commit 80286e8f811341e6054a85b69e2573a778ba42cf

Authored by Heinrich Schuchardt
Committed by Alexander Graf
1 parent 9449358a71

efi_loader: simplify efi_open_protocol

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>

Showing 1 changed file with 6 additions and 30 deletions Side-by-side Diff

lib/efi_loader/efi_boottime.c
... ... @@ -2051,8 +2051,7 @@
2051 2051 void **protocol_interface, void *agent_handle,
2052 2052 void *controller_handle, uint32_t attributes)
2053 2053 {
2054   - struct list_head *lhandle;
2055   - int i;
  2054 + struct efi_handler *handler;
2056 2055 efi_status_t r = EFI_INVALID_PARAMETER;
2057 2056  
2058 2057 EFI_ENTRY("%p, %pUl, %p, %p, %p, 0x%x", handle, protocol,
... ... @@ -2065,8 +2064,6 @@
2065 2064 goto out;
2066 2065 }
2067 2066  
2068   - EFI_PRINT_GUID("protocol", protocol);
2069   -
2070 2067 switch (attributes) {
2071 2068 case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
2072 2069 case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
2073 2070  
... ... @@ -2087,33 +2084,12 @@
2087 2084 goto out;
2088 2085 }
2089 2086  
2090   - list_for_each(lhandle, &efi_obj_list) {
2091   - struct efi_object *efiobj;
2092   - efiobj = list_entry(lhandle, struct efi_object, link);
  2087 + r = efi_search_protocol(handle, protocol, &handler);
  2088 + if (r != EFI_SUCCESS)
  2089 + goto out;
2093 2090  
2094   - if (efiobj->handle != handle)
2095   - continue;
2096   -
2097   - for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
2098   - struct efi_handler *handler = &efiobj->protocols[i];
2099   - const efi_guid_t *hprotocol = handler->guid;
2100   - if (!hprotocol)
2101   - continue;
2102   - if (!guidcmp(hprotocol, protocol)) {
2103   - if (attributes !=
2104   - EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
2105   - *protocol_interface =
2106   - handler->protocol_interface;
2107   - }
2108   - r = EFI_SUCCESS;
2109   - goto out;
2110   - }
2111   - }
2112   - goto unsupported;
2113   - }
2114   -
2115   -unsupported:
2116   - r = EFI_UNSUPPORTED;
  2091 + if (attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL)
  2092 + *protocol_interface = handler->protocol_interface;
2117 2093 out:
2118 2094 return EFI_EXIT(r);
2119 2095 }