[U-Boot] [PATCH] dm: core: don't fail to iterate if first one fails to probe

Peter Robinson pbrobinson at gmail.com
Wed Jun 21 10:23:10 UTC 2017


On Tue, Jun 20, 2017 at 10:49 PM, Rob Clark <robdclark at gmail.com> wrote:
> efi_disk_register() would try to iterate all the blk devices.  But if
> the first one in the list failed to probe, uclass_first_device() would
> return NULL and no attempt would be made to register the remaining
> devices.  Also uclass_next_device() needs the same fix.

This looks related/similar to the "efi_loader: disk: iterate only over
valid block devices" patch [1]

Peter

[1] https://lists.denx.de/pipermail/u-boot/2017-June/296015.html


> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
>  drivers/core/uclass.c | 24 +++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index 21dc696..c47ff56 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -458,14 +458,23 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,
>
>  int uclass_first_device(enum uclass_id id, struct udevice **devp)
>  {
> -       struct udevice *dev;
> +       struct udevice *dev = NULL;
>         int ret;
>
>         *devp = NULL;
>         ret = uclass_find_first_device(id, &dev);
>         if (!dev)
>                 return 0;
> -       return uclass_get_device_tail(dev, ret, devp);
> +       ret = uclass_get_device_tail(dev, ret, devp);
> +       if (ret && dev) {
> +               /* we have a device, but it failed to probe, move on and
> +                * try the next one.
> +                */
> +               ret = uclass_next_device(&dev);
> +               if (!ret)
> +                       *devp = dev;
> +       }
> +       return ret;
>  }
>
>  int uclass_first_device_err(enum uclass_id id, struct udevice **devp)
> @@ -490,7 +499,16 @@ int uclass_next_device(struct udevice **devp)
>         ret = uclass_find_next_device(&dev);
>         if (!dev)
>                 return 0;
> -       return uclass_get_device_tail(dev, ret, devp);
> +       ret = uclass_get_device_tail(dev, ret, devp);
> +       if (ret && (dev != *devp)) {
> +               /* we have a device, but it failed to probe, move on and
> +                * try the next one.
> +                */
> +               ret = uclass_next_device(&dev);
> +               if (!ret)
> +                       *devp = dev;
> +       }
> +       return ret;
>  }
>
>  int uclass_bind_device(struct udevice *dev)
> --
> 2.9.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot


More information about the U-Boot mailing list