]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: function to unlink udevice and handle
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 3 Oct 2022 07:47:51 +0000 (09:47 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 6 Oct 2022 20:54:57 +0000 (22:54 +0200)
When deleting a device or a handle we must remove the link between the two
to avoid dangling references.

Provide function efi_unlink_dev() for this purpose.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
include/efi_loader.h
lib/efi_loader/efi_helper.c

index 8c45e3ee25925e56b1dfa3f4c9c1114c05bc6621..6f78f774047912ec62432ae96f9a23831c39b598 100644 (file)
@@ -708,6 +708,7 @@ const char *guid_to_sha_str(const efi_guid_t *guid);
 int algo_to_len(const char *algo);
 
 int efi_link_dev(efi_handle_t handle, struct udevice *dev);
+int efi_unlink_dev(efi_handle_t handle);
 
 /**
  * efi_size_in_pages() - convert size in bytes to size in pages
index 8ed564e26194b1385a932bb56ed2208f5de263af..c71e87d118030af05d32b7619c0497f6c1b0b592 100644 (file)
@@ -171,3 +171,22 @@ int efi_link_dev(efi_handle_t handle, struct udevice *dev)
        handle->dev = dev;
        return dev_tag_set_ptr(dev, DM_TAG_EFI, handle);
 }
+
+/**
+ * efi_unlink_dev() - unlink udevice and handle
+ *
+ * @handle:    EFI handle to unlink
+ *
+ * Return:     0 on success, negative on failure
+ */
+int efi_unlink_dev(efi_handle_t handle)
+{
+       int ret;
+
+       ret = dev_tag_del(handle->dev, DM_TAG_EFI);
+       if (ret)
+               return ret;
+       handle->dev = NULL;
+
+       return 0;
+}