[PATCH 1/1] dm: simplify uclass_pre_remove_device

Simon Glass sjg at chromium.org
Sat Mar 18 21:20:30 CET 2023


Hi Heinrich,

On Sat, 18 Mar 2023 at 03:56, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> Remove a superfluous logical constraint.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
>  drivers/core/uclass.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)

Where possible I like to keep the happy path clear, so that we always
exit with 0.  I know this results in a little more code, but it does
not affect the compiler output. I think it makes it easier to see when
things pass or fail.

>
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index 1762a0796d..dce5b46fc7 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -789,14 +789,10 @@ int uclass_post_probe_device(struct udevice *dev)
>  int uclass_pre_remove_device(struct udevice *dev)
>  {
>         struct uclass *uc;
> -       int ret;
>
>         uc = dev->uclass;
> -       if (uc->uc_drv->pre_remove) {
> -               ret = uc->uc_drv->pre_remove(dev);
> -               if (ret)
> -                       return ret;
> -       }
> +       if (uc->uc_drv->pre_remove)
> +               return uc->uc_drv->pre_remove(dev);
>
>         return 0;
>  }
> --
> 2.39.2
>

Regards,
Simon


More information about the U-Boot mailing list