[U-Boot] [PATCH v2 3/7] drivers: block: disk-uclass: implement scsi_init()

Simon Glass sjg at chromium.org
Sat Feb 6 21:29:34 CET 2016


Hi Bin,

On 3 February 2016 at 04:59, Mugunthan V N <mugunthanvnm at ti.com> wrote:
>
> Implement scsi_init() api to probe driver model based sata
> devices.
>
> Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
> ---
>  drivers/block/disk-uclass.c | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)

This patch seems odd to me. I would hope that scsi_init() would go
away with driver model and it would happen as part of the controller
probe. But of course we cannot probe SCSI from UCLASS_DISK. I think
the uclass 'disk' is too broad to be useful.

So I am wondering whether the decision to use UCLASS_DISK instead of
UCLASS_AHCI was a mistake.

Perhaps instead we should have:

UCLASS_AHCI
UCLASS_SCSI
UCLASS_MMC
etc...

and each of these devices can have a UCLASS_BLK under them (the block device).

Possibly we could even have a dummy UCLASS_DISK device under each of
the above, but I'm not sure that is useful.

What do you think?

>
> diff --git a/drivers/block/disk-uclass.c b/drivers/block/disk-uclass.c
> index d665b35..4bd7b56 100644
> --- a/drivers/block/disk-uclass.c
> +++ b/drivers/block/disk-uclass.c
> @@ -7,6 +7,45 @@
>
>  #include <common.h>
>  #include <dm.h>
> +#include <dm/uclass-internal.h>
> +#include <dm/device-internal.h>
> +#include <scsi.h>
> +
> +int scsi_get_device(int index, struct udevice **devp)
> +{
> +       struct udevice *dev;
> +       int ret;
> +
> +       ret = uclass_find_device(UCLASS_DISK, index, &dev);
> +       if (ret || !dev) {
> +               printf("%d device not found\n", index);
> +               return ret;
> +       }
> +
> +       ret = device_probe(dev);
> +       if (ret) {
> +               error("device probe error\n");
> +               return ret;
> +       }
> +
> +       *devp = dev;
> +
> +       return ret;
> +}
> +
> +void scsi_init(void)
> +{
> +       struct udevice *dev;
> +       int ret;
> +
> +       ret = scsi_get_device(0, &dev);
> +       if (ret || !dev) {
> +               error("scsi device not found\n");
> +               return;
> +       }
> +
> +       scsi_scan(1);
> +}
>
>  UCLASS_DRIVER(disk) = {
>         .id             = UCLASS_DISK,
> --
> 2.7.0.75.g3ee1e0f
>

Regards,
Simon


More information about the U-Boot mailing list