On 9/13/21 8:01 AM, AKASHI Takahiro wrote:
blk_create_devicef() is what blk_create_device() +
device_set_name_alloced() really does.
The resultant name will be a bit changed.

without the patch after a device has been generated by the UEFI subsystem:

=> dm tree

Class Index  Probed  Driver      Name

-----------------------------------------
root      0  [ + ]   root_driver root_driver
mmc       2  [ + ]   mmc_sandbox |-- mmc0

blk       2  [ + ]   mmc_blk     |   `-- mmc0.blk
blk       3  [ + ]   efi_blk     `-- efiblk#0

with the patch:

=> dm tree

Class Index  Probed  Driver      Name

---------------------------------------------------------

root      0  [ + ]   root_driver root_driver
mmc       2  [ + ]   mmc_sandbox |-- mmc0

blk       2  [ + ]   mmc_blk     |   `-- mmc0.blk
blk       3  [ + ]   efi_blk     `-- root_driver.efiblk#0

Prepending 'root_driver.' to the name seems to not match the rest of the
tree.

Best regards

Heinrich


Signed-off-by: AKASHI Takahiro <takahiro.aka...@linaro.org>
---
  lib/efi_driver/efi_block_device.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/lib/efi_driver/efi_block_device.c 
b/lib/efi_driver/efi_block_device.c
index 0937e3595a43..b81c75868eb4 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -159,15 +159,11 @@ static int efi_bl_bind(efi_handle_t handle, void 
*interface)
        sprintf(name, "efiblk#%d", devnum);

        /* Create driver model udevice for the EFI block io device */
-       ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI, devnum,
-                               io->media->block_size,
-                               (lbaint_t)io->media->last_block, &bdev);
+       ret = blk_create_devicef(parent, "efi_blk", name, IF_TYPE_EFI, devnum,
+                                io->media->block_size,
+                                (lbaint_t)io->media->last_block, &bdev);
        if (ret)
                return ret;
-       if (!bdev)
-               return -ENOENT;
-       /* Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak */
-       device_set_name_alloced(bdev);

        plat = dev_get_plat(bdev);
        plat->handle = handle;


Reply via email to