]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
efi: Create the grub_efi_close_protocol() library function
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 29 Nov 2021 15:00:29 +0000 (16:00 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Dec 2021 00:33:13 +0000 (01:33 +0100)
Create a library function for CloseProtocol() and use it for the SNP driver.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/efi/efi.c
grub-core/net/drivers/efi/efinet.c
include/grub/efi/efi.h

index 8cff7be028930529768f729a8cb525c0e09f1668..18858c3279c543c6244ea3873b88b647ef69645b 100644 (file)
@@ -117,6 +117,14 @@ grub_efi_open_protocol (grub_efi_handle_t handle,
   return interface;
 }
 
+grub_efi_status_t
+grub_efi_close_protocol (grub_efi_handle_t handle, grub_efi_guid_t *protocol)
+{
+  grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
+
+  return efi_call_4 (b->close_protocol, handle, protocol, grub_efi_image_handle, NULL);
+}
+
 int
 grub_efi_set_text_mode (int on)
 {
index 2c81fd0d4fd79f295716fe45871b9e81fb8bc4da..381c138db6d47b55148c42759fdef1c657d4e65c 100644 (file)
@@ -156,9 +156,7 @@ open_card (struct grub_net_card *dev)
 
   if (dev->efi_net != NULL)
     {
-      efi_call_4 (grub_efi_system_table->boot_services->close_protocol,
-                 dev->efi_handle, &net_io_guid,
-                 grub_efi_image_handle, NULL);
+      grub_efi_close_protocol (dev->efi_handle, &net_io_guid);
       dev->efi_net = NULL;
     }
   /*
@@ -220,9 +218,7 @@ close_card (struct grub_net_card *dev)
 {
   efi_call_1 (dev->efi_net->shutdown, dev->efi_net);
   efi_call_1 (dev->efi_net->stop, dev->efi_net);
-  efi_call_4 (grub_efi_system_table->boot_services->close_protocol,
-             dev->efi_handle, &net_io_guid,
-             grub_efi_image_handle, 0);
+  grub_efi_close_protocol (dev->efi_handle, &net_io_guid);
 }
 
 static struct grub_net_card_driver efidriver =
index 83d958f9945ed90fe5b5f3c1be75ac6f417ff342..fc723962d77099a6ef95b6267dd299c3d443548f 100644 (file)
@@ -35,6 +35,8 @@ EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type,
 void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
                                           grub_efi_guid_t *protocol,
                                           grub_efi_uint32_t attributes);
+grub_efi_status_t
+EXPORT_FUNC(grub_efi_close_protocol) (grub_efi_handle_t handle, grub_efi_guid_t *protocol);
 int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
 void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
 void *