[U-Boot] [RFC v2 14/15] efi_driver: converted to DM

AKASHI Takahiro takahiro.akashi at linaro.org
Fri Feb 8 08:15:41 UTC 2019


Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 lib/efi_driver/efi_block_device.c |  4 ----
 lib/efi_driver/efi_uclass.c       | 27 ++++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index acef1b20867e..f3e7ebf6dc5e 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -118,16 +118,12 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
 	struct udevice *bdev, *parent = dm_root();
 	int ret, devnum;
 	char *name;
-	struct efi_object *obj = efi_search_obj(handle);
 	struct efi_block_io *io = interface;
 	int disks;
 	struct efi_blk_platdata *platdata;
 
 	EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io);
 
-	if (!obj)
-		return -ENOENT;
-
 	devnum = blk_find_max_devnum(IF_TYPE_EFI);
 	if (devnum == -ENODEV)
 		devnum = 0;
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index d42612a5ee03..bf6bc79837ba 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -18,6 +18,8 @@
  */
 
 #include <efi_driver.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
 
 /**
  * check_node_type() - check node type
@@ -272,8 +274,18 @@ static efi_status_t efi_add_driver(struct driver *drv)
 	bp->bp.version = 0xffffffff;
 	bp->ops = drv->ops;
 
-	ret = efi_create_handle(&bp->bp.driver_binding_handle);
+	ret = device_bind_driver(efi_root, drv->name, drv->name,
+				 &bp->bp.driver_binding_handle);
+	if (ret) {
+		free(bp);
+		goto out;
+	}
+
+	ret = efi_add_handle(bp->bp.driver_binding_handle);
 	if (ret != EFI_SUCCESS) {
+#ifdef CONFIG_DM_DEVICE_REMOVE
+		device_unbind(bp->bp.driver_binding_handle);
+#endif
 		free(bp);
 		goto out;
 	}
@@ -349,3 +361,16 @@ UCLASS_DRIVER(efi_driver) = {
 	.init		= efi_uc_init,
 	.destroy	= efi_uc_destroy,
 };
+
+static int efi_driver_binding_probe(struct udevice *dev)
+{
+	device_set_name(dev, "DRIVER_BINDING");
+
+	return 0;
+}
+
+U_BOOT_DRIVER(efi_driver_binding) = {
+	.name = "efi_driver_binding",
+	.id = UCLASS_EFI_PROTOCOL,
+	.probe = efi_driver_binding_probe,
+};
-- 
2.19.1



More information about the U-Boot mailing list