[PATCH 1/2] reset: Do not return NULL on error for devm_reset_control_get_optional()

Simon Glass sjg at chromium.org
Fri May 7 18:34:32 CEST 2021


Hi Kishon,

On Fri, 7 May 2021 at 05:02, Kishon Vijay Abraham I <kishon at ti.com> wrote:
>
> In order for client to know whether it was able to successfully get a
> reset controller or not, do not return NULL on error for
> devm_reset_control_get_optional() and
> devm_reset_bulk_get_optional_by_node().
>
> Signed-off-by: Kishon Vijay Abraham I <kishon at ti.com>
> ---
>  drivers/reset/reset-uclass.c       | 16 ++--------------
>  drivers/reset/sandbox-reset-test.c |  2 +-
>  2 files changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
> index ac89eaf098..906f58ce3d 100644
> --- a/drivers/reset/reset-uclass.c
> +++ b/drivers/reset/reset-uclass.c
> @@ -299,12 +299,7 @@ struct reset_ctl *devm_reset_control_get(struct udevice *dev, const char *id)
>  struct reset_ctl *devm_reset_control_get_optional(struct udevice *dev,
>                                                   const char *id)
>  {
> -       struct reset_ctl *r = devm_reset_control_get(dev, id);
> -
> -       if (IS_ERR(r))
> -               return NULL;
> -
> -       return r;
> +       return devm_reset_control_get(dev, id);
>  }

We need to get some updates to the API (function comments in the
header) here. I'm not sure what the intent is.

I thought these functions were going to return a valid (but possibly
empty) reset_ctl always?

>
>  static void devm_reset_bulk_release(struct udevice *dev, void *res)
> @@ -337,14 +332,7 @@ struct reset_ctl_bulk *devm_reset_bulk_get_by_node(struct udevice *dev,
>  struct reset_ctl_bulk *devm_reset_bulk_get_optional_by_node(struct udevice *dev,
>                                                             ofnode node)
>  {
> -       struct reset_ctl_bulk *bulk;
> -
> -       bulk = devm_reset_bulk_get_by_node(dev, node);
> -
> -       if (IS_ERR(bulk))
> -               return NULL;
> -
> -       return bulk;
> +       return devm_reset_bulk_get_by_node(dev, node);
>  }
>
>  struct reset_ctl_bulk *devm_reset_bulk_get(struct udevice *dev)
> diff --git a/drivers/reset/sandbox-reset-test.c b/drivers/reset/sandbox-reset-test.c
> index 51b79810c8..2a810fda3a 100644
> --- a/drivers/reset/sandbox-reset-test.c
> +++ b/drivers/reset/sandbox-reset-test.c
> @@ -38,7 +38,7 @@ int sandbox_reset_test_get_devm(struct udevice *dev)
>                 return -EINVAL;
>
>         r = devm_reset_control_get_optional(dev, "not-a-valid-reset-ctl");
> -       if (r)
> +       if (IS_ERR(r) && PTR_ERR(r) != -ENODATA)
>                 return -EINVAL;
>
>         sbrt->ctlp = devm_reset_control_get(dev, "test");
> --
> 2.17.1
>

Regards,
SImon


More information about the U-Boot mailing list