public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 3/3] drivers: align block device drivers with DM-efi integration
Date: Tue, 29 Jan 2019 17:19:38 +0100	[thread overview]
Message-ID: <ab81bc06-ce21-ea26-3bb6-98aca5fc9446@suse.de> (raw)
In-Reply-To: <20190129025956.21870-4-takahiro.akashi@linaro.org>

On 01/29/2019 03:59 AM, AKASHI Takahiro wrote:
> Efi_disk_create() should be hook up at every creation of block device
> at each driver. Associated blk_desc must be properly set up before
> calling this function.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>   common/usb_storage.c              | 27 +++++++++++++++++++++++++--
>   drivers/scsi/scsi.c               | 22 ++++++++++++++++++++++
>   lib/efi_driver/efi_block_device.c | 30 +++++++++---------------------
>   3 files changed, 56 insertions(+), 23 deletions(-)
>
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index 8c889bb1a648..ff895c0e4557 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -46,6 +46,10 @@
>   #include <part.h>
>   #include <usb.h>
>   
> +/* FIXME */
> +extern int efi_disk_create(struct udevice *dev);
> +extern int blk_create_partitions(struct udevice *parent);
> +
>   #undef BBB_COMDAT_TRACE
>   #undef BBB_XPORT_TRACE
>   
> @@ -227,8 +231,27 @@ static int usb_stor_probe_device(struct usb_device *udev)
>   
>   		ret = usb_stor_get_info(udev, data, blkdev);
>   		if (ret == 1) {
> -			usb_max_devs++;
> -			debug("%s: Found device %p\n", __func__, udev);
> +			ret = efi_disk_create(dev);
> +			if (ret) {
> +				debug("Cannot create efi_disk device\n");
> +				ret = device_unbind(dev);
> +				if (ret)
> +					return ret;
> +			} else {
> +				usb_max_devs++;
> +				ret = blk_create_partitions(dev);
> +				if (ret < 0) {
> +					debug("Cannot create disk partition device\n");
> +					/* TODO: undo create */
> +
> +					ret = device_unbind(dev);
> +					if (ret)
> +						return ret;
> +				}
> +				usb_max_devs += ret;
> +				debug("%s: Found device %p, partitions:%d\n",
> +				      __func__, udev, ret);
> +			}

Why do we need to do this in device specific code?

Alex


>   		} else {
>   			debug("usb_stor_get_info: Invalid device\n");
>   			ret = device_unbind(dev);
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index df47e2fc78bd..f0f8cbc0bf26 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -11,6 +11,10 @@
>   #include <dm/device-internal.h>
>   #include <dm/uclass-internal.h>
>   
> +/* FIXME */
> +int efi_disk_create(struct udevice *dev);
> +int blk_create_partitions(struct udevice *parent);
> +
>   #if !defined(CONFIG_DM_SCSI)
>   # ifdef CONFIG_SCSI_DEV_LIST
>   #  define SCSI_DEV_LIST CONFIG_SCSI_DEV_LIST
> @@ -593,9 +597,27 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
>   	memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
>   	memcpy(&bdesc->revision, &bd.revision,	sizeof(bd.revision));
>   
> +	ret = efi_disk_create(bdev);
> +	if (ret) {
> +		debug("Can't create efi_disk device\n");
> +		ret = device_unbind(bdev);
> +
> +		return ret;
> +	}
> +	ret = blk_create_partitions(bdev);
> +	if (ret < 0) {
> +		debug("Can't create efi_disk partitions\n");
> +		/* TODO: undo create */
> +
> +		ret = device_unbind(bdev);
> +
> +		return ret;
> +	}
> +
>   	if (verbose) {
>   		printf("  Device %d: ", 0);
>   		dev_print(bdesc);
> +		debug("Found %d partitions\n", ret);
>   	}
>   	return 0;
>   }
> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
> index 3f147cf60879..4ab3402d6768 100644
> --- a/lib/efi_driver/efi_block_device.c
> +++ b/lib/efi_driver/efi_block_device.c
> @@ -32,6 +32,10 @@
>   #include <dm/device-internal.h>
>   #include <dm/root.h>
>   
> +/* FIXME */
> +extern int efi_disk_create(struct udevice *dev);
> +extern int blk_create_partitions(struct udevice *parent);
> +
>   /*
>    * EFI attributes of the udevice handled by this driver.
>    *
> @@ -102,24 +106,6 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
>   	return blkcnt;
>   }
>   
> -/*
> - * Create partions for the block device.
> - *
> - * @handle	EFI handle of the block device
> - * @dev		udevice of the block device
> - */
> -static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev)
> -{
> -	struct blk_desc *desc;
> -	const char *if_typename;
> -
> -	desc = dev_get_uclass_platdata(dev);
> -	if_typename = blk_get_if_type_name(desc->if_type);
> -
> -	return efi_disk_create_partitions(handle, desc, if_typename,
> -					  desc->devnum, dev->name);
> -}
> -
>   /*
>    * Create a block device for a handle
>    *
> @@ -168,15 +154,17 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
>   	platdata->handle = handle;
>   	platdata->io = interface;
>   
> +	ret = efi_disk_create(bdev);
> +	if (ret)
> +		return ret;
> +
>   	ret = device_probe(bdev);
>   	if (ret)
>   		return ret;
>   	EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
> -
>   	/* Create handles for the partions of the block device */
> -	disks = efi_bl_bind_partitions(handle, bdev);
> +	disks = blk_create_partitions(bdev);
>   	EFI_PRINT("Found %d partitions\n", disks);
> -
>   	return 0;
>   }
>   

  reply	other threads:[~2019-01-29 16:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  2:59 [U-Boot] [RFC 0/3] dm, efi: integrate efi_disk into DM AKASHI Takahiro
2019-01-29  2:59 ` [U-Boot] [RFC 1/3] dm: blk: add UCLASS_PARTITION AKASHI Takahiro
2019-01-29  3:17   ` Sergey Kubushyn
2019-01-29 15:37     ` Alexander Graf
2019-01-29 17:46       ` Sergey Kubushyn
2019-01-29 18:02         ` Philipp Tomsich
2019-01-29 22:20   ` Heinrich Schuchardt
2019-01-30  5:28     ` AKASHI Takahiro
2019-01-31  1:00   ` Simon Glass
2019-01-29  2:59 ` [U-Boot] [RFC 2/3] efi_loader: associate BLK/PARTITION device to efi_disk AKASHI Takahiro
2019-01-29 22:33   ` Heinrich Schuchardt
2019-01-30  5:48     ` AKASHI Takahiro
2019-01-30  6:49       ` Heinrich Schuchardt
2019-01-30  7:26         ` AKASHI Takahiro
2019-01-31  1:22   ` Simon Glass
2019-02-01  5:54     ` AKASHI Takahiro
2019-02-02 14:15       ` Simon Glass
2019-02-06  3:15         ` AKASHI Takahiro
2019-02-06  7:54           ` AKASHI Takahiro
2019-01-29  2:59 ` [U-Boot] [RFC 3/3] drivers: align block device drivers with DM-efi integration AKASHI Takahiro
2019-01-29 16:19   ` Alexander Graf [this message]
2019-01-30  0:40     ` AKASHI Takahiro
2019-01-29 16:20 ` [U-Boot] [RFC 0/3] dm, efi: integrate efi_disk into DM Alexander Graf
2019-01-29 22:48   ` Heinrich Schuchardt
2019-01-30  5:18     ` AKASHI Takahiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab81bc06-ce21-ea26-3bb6-98aca5fc9446@suse.de \
    --to=agraf@suse.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox