Message ID | 20170826225328.7550-2-xypron.glpk@gmx.de |
---|---|
State | Superseded, archived |
Delegated to: | Alexander Graf |
Headers | show |
On 27 August 2017 at 06:53, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > efi_open_protocol and efi_close_protocol have to keep track of > opened protocols. > > efi_close_protocol has to mark the appropriate entry as > empty. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > lib/efi_loader/efi_boottime.c | 33 ++++++++++++++++++++++++++++++++- > 1 file changed, 32 insertions(+), 1 deletion(-) Reviewed-by: Simon Glass <sjg@chromium.org> Again I wonder if you can use a utility function to find the slot. > > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c > index 294bc1f138..c9aec597a2 100644 > --- a/lib/efi_loader/efi_boottime.c > +++ b/lib/efi_loader/efi_boottime.c > @@ -944,9 +944,40 @@ static efi_status_t EFIAPI efi_close_protocol(void *handle, > void *agent_handle, > void *controller_handle) > { > + struct efi_handler *handler; > + size_t i; > + struct efi_open_protocol_info_entry *open_info; > + efi_status_t r; > + > EFI_ENTRY("%p, %p, %p, %p", handle, protocol, agent_handle, > controller_handle); > - return EFI_EXIT(EFI_NOT_FOUND); > + > + if (!agent_handle) { > + r = EFI_INVALID_PARAMETER; > + goto out; > + } > + > + r = efi_search_protocol(handle, protocol, &handler); > + if (r != EFI_SUCCESS) > + goto out; > + > + for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) { > + open_info = &handler->open_info[i]; > + > + if (!open_info->open_count) > + continue; > + > + if (open_info->agent_handle == agent_handle && > + open_info->controller_handle == > + controller_handle) { > + open_info->open_count--; > + r = EFI_SUCCESS; > + goto out; > + } > + } > + r = EFI_NOT_FOUND; > +out: > + return EFI_EXIT(r); > } > > static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle, > -- > 2.14.1 >
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 294bc1f138..c9aec597a2 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -944,9 +944,40 @@ static efi_status_t EFIAPI efi_close_protocol(void *handle, void *agent_handle, void *controller_handle) { + struct efi_handler *handler; + size_t i; + struct efi_open_protocol_info_entry *open_info; + efi_status_t r; + EFI_ENTRY("%p, %p, %p, %p", handle, protocol, agent_handle, controller_handle); - return EFI_EXIT(EFI_NOT_FOUND); + + if (!agent_handle) { + r = EFI_INVALID_PARAMETER; + goto out; + } + + r = efi_search_protocol(handle, protocol, &handler); + if (r != EFI_SUCCESS) + goto out; + + for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) { + open_info = &handler->open_info[i]; + + if (!open_info->open_count) + continue; + + if (open_info->agent_handle == agent_handle && + open_info->controller_handle == + controller_handle) { + open_info->open_count--; + r = EFI_SUCCESS; + goto out; + } + } + r = EFI_NOT_FOUND; +out: + return EFI_EXIT(r); } static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
efi_open_protocol and efi_close_protocol have to keep track of opened protocols. efi_close_protocol has to mark the appropriate entry as empty. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- lib/efi_loader/efi_boottime.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)