
On 27 August 2017 at 06:51, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
In multiple functions we are searching for the protocol of a handle. This patch provides a new function efi_search_protocol that we can use to avoid duplicating code.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
lib/efi_loader/efi_boottime.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b643d299b9..9dae02daca 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -453,6 +453,31 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event) return EFI_EXIT(EFI_INVALID_PARAMETER); }
+static efi_status_t efi_search_protocol(void *handle, efi_guid_t *protocol_guid,
struct efi_handler **handler)
Needs a function comment
+{
struct efi_object *efiobj;
size_t i;
struct efi_handler *protocol;
if (!handle || !protocol_guid)
return EFI_INVALID_PARAMETER;
efiobj = efi_search_obj(handle);
if (!efiobj)
return EFI_INVALID_PARAMETER;
for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
protocol = &efiobj->protocols[i];
if (!protocol->guid)
continue;
if (!guidcmp(protocol->guid, protocol_guid)) {
if (handler)
*handler = protocol;
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
+}
static efi_status_t EFIAPI efi_install_protocol_interface(void **handle, efi_guid_t *protocol, int protocol_interface_type, void *protocol_interface) -- 2.14.1