|
35 | 35 | #include <efi_driver.h>
|
36 | 36 | #include <malloc.h>
|
37 | 37 | #include <dm/device-internal.h>
|
| 38 | +#include <dm/lists.h> |
38 | 39 | #include <dm/root.h>
|
39 | 40 | #include <dm/tag.h>
|
| 41 | +#include <dm/uclass-internal.h> |
40 | 42 |
|
41 | 43 | /**
|
42 | 44 | * struct efi_blk_plat - attributes of a block device
|
@@ -118,13 +120,18 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
118 | 120 | static efi_status_t
|
119 | 121 | efi_bl_create_block_device(efi_handle_t handle, void *interface)
|
120 | 122 | {
|
121 |
| - struct udevice *bdev = NULL, *parent = dm_root(); |
| 123 | + struct udevice *bdev = NULL, *parent; |
122 | 124 | efi_status_t ret;
|
| 125 | + int r; |
123 | 126 | int devnum;
|
124 | 127 | char *name;
|
125 | 128 | struct efi_block_io *io = interface;
|
126 | 129 | struct efi_blk_plat *plat;
|
127 | 130 |
|
| 131 | + r = uclass_find_first_device(UCLASS_EFI_LOADER, &parent); |
| 132 | + if (r) |
| 133 | + return EFI_OUT_OF_RESOURCES; |
| 134 | + |
128 | 135 | devnum = blk_next_free_devnum(UCLASS_EFI_LOADER);
|
129 | 136 | if (devnum < 0)
|
130 | 137 | return EFI_OUT_OF_RESOURCES;
|
@@ -221,6 +228,24 @@ efi_bl_init(struct efi_driver_binding_extended_protocol *this)
|
221 | 228 | return EFI_SUCCESS;
|
222 | 229 | }
|
223 | 230 |
|
| 231 | +/** |
| 232 | + * efi_block_device_create() - create parent for EFI block devices |
| 233 | + * |
| 234 | + * Create a device that serves as parent for all block devices created via |
| 235 | + * ConnectController(). |
| 236 | + * |
| 237 | + * Return: 0 for success |
| 238 | + */ |
| 239 | +static int efi_block_device_create(void) |
| 240 | +{ |
| 241 | + int ret; |
| 242 | + struct udevice *dev; |
| 243 | + |
| 244 | + ret = device_bind_driver(gd->dm_root, "EFI block driver", "efi", &dev); |
| 245 | + |
| 246 | + return ret; |
| 247 | +} |
| 248 | + |
224 | 249 | /* Block device driver operators */
|
225 | 250 | static const struct blk_ops efi_blk_ops = {
|
226 | 251 | .read = efi_bl_read,
|
@@ -249,3 +274,5 @@ U_BOOT_DRIVER(efi_block) = {
|
249 | 274 | .id = UCLASS_EFI_LOADER,
|
250 | 275 | .ops = &driver_ops,
|
251 | 276 | };
|
| 277 | + |
| 278 | +EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, efi_block_device_create); |
0 commit comments