[PATCH 17/19] efi_loader: disk: use udevice instead of blk_desc

Heinrich Schuchardt xypron.glpk at gmx.de
Sat Feb 5 10:02:19 CET 2022


On 2/2/22 02:08, AKASHI Takahiro wrote:
> In most of all cases, we can avoid using blk_desc which is expected
> to be private to udevice(UCLASS_BLK), that is, the data should not
> be manupulated outside the device driver unless really needed.
>
> Now efi_disk's internally use dev_read/write() interfaces.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> ---
>   lib/efi_loader/efi_disk.c | 25 ++++++++++++-------------
>   1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index 8dc7534278da..8e33af76711f 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -48,7 +48,7 @@ struct efi_disk_obj {
>   	unsigned int part;
>   	struct efi_simple_file_system_protocol *volume;
>   	lbaint_t offset;
> -	struct blk_desc *desc;
> +	struct udevice *dev; /* TODO: move it to efi_object */

This breaks 'make htmldocs'. Add the missing description.

./include/asm-generic/global_data.h:474: warning: Function parameter or
member 'event_state' not described in 'global_data'

Best regards

Heinrich

>   };
>
>   /**
> @@ -83,14 +83,12 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
>   			void *buffer, enum efi_disk_direction direction)
>   {
>   	struct efi_disk_obj *diskobj;
> -	struct blk_desc *desc;
>   	int blksz;
>   	int blocks;
>   	unsigned long n;
>
>   	diskobj = container_of(this, struct efi_disk_obj, ops);
> -	desc = (struct blk_desc *) diskobj->desc;
> -	blksz = desc->blksz;
> +	blksz = diskobj->media.block_size;
>   	blocks = buffer_size / blksz;
>   	lba += diskobj->offset;
>
> @@ -102,9 +100,9 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
>   		return EFI_BAD_BUFFER_SIZE;
>
>   	if (direction == EFI_DISK_READ)
> -		n = blk_dread(desc, lba, blocks, buffer);
> +		n = dev_read(diskobj->dev, lba, blocks, buffer);
>   	else
> -		n = blk_dwrite(desc, lba, blocks, buffer);
> +		n = dev_write(diskobj->dev, lba, blocks, buffer);
>
>   	/* We don't do interrupts, so check for timers cooperatively */
>   	efi_timer_check();
> @@ -446,7 +444,6 @@ static efi_status_t efi_disk_add_dev(
>   	diskobj->ops = block_io_disk_template;
>   	diskobj->ifname = if_typename;
>   	diskobj->dev_index = dev_index;
> -	diskobj->desc = desc;
>
>   	/* Fill in EFI IO Media info (for read/write callbacks) */
>   	diskobj->media.removable_media = desc->removable;
> @@ -745,20 +742,22 @@ bool efi_disk_is_system_part(efi_handle_t handle)
>   {
>   	struct efi_handler *handler;
>   	struct efi_disk_obj *diskobj;
> -	struct disk_partition info;
> +	struct udevice *dev;
> +	struct disk_part *part;
>   	efi_status_t ret;
> -	int r;
>
>   	/* check if this is a block device */
>   	ret = efi_search_protocol(handle, &efi_block_io_guid, &handler);
>   	if (ret != EFI_SUCCESS)
>   		return false;
>
> +	/* find a partition udevice */
>   	diskobj = container_of(handle, struct efi_disk_obj, header);
> -
> -	r = part_get_info(diskobj->desc, diskobj->part, &info);
> -	if (r)
> +	dev = diskobj->dev;
> +	if (!dev || dev->driver->id != UCLASS_PARTITION)
>   		return false;
>
> -	return !!(info.bootable & PART_EFI_SYSTEM_PARTITION);
> +	part = dev_get_uclass_plat(dev);
> +
> +	return !!(part->gpt_part_info.bootable & PART_EFI_SYSTEM_PARTITION);
>   }



More information about the U-Boot mailing list