diff mbox series

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

Message ID 20190208081542.2813-15-takahiro.akashi@linaro.org
State RFC
Delegated to: Alexander Graf
Headers show
Series dm, efi: integrate efi objects into DM | expand

Commit Message

AKASHI Takahiro Feb. 8, 2019, 8:15 a.m. UTC
Signed-off-by: AKASHI Takahiro <takahiro.akashi@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 mbox series

Patch

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,
+};