[PATCH 5/6] efi_loader: simplify efi_dp_from_name()

Ilias Apalodimas ilias.apalodimas at linaro.org
Mon May 15 10:21:41 CEST 2023


On Sat, 13 May 2023 at 11:48, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> Don't do the same check and assignment in multiple places.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
>  lib/efi_loader/efi_device_path.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index 1436244f99..a9b0ea4015 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -1185,6 +1185,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
>                               struct efi_device_path **file)
>  {
>         struct blk_desc *desc = NULL;
> +       struct efi_device_path *dp;
>         struct disk_partition fs_partition;
>         size_t image_size;
>         void *image_addr;
> @@ -1197,25 +1198,22 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
>                 /* loadm command and semihosting */
>                 efi_get_image_parameters(&image_addr, &image_size);
>
> -               if (device)
> -                       *device = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
> -                                                 (uintptr_t)image_addr,
> -                                                 image_size);
> +               dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
> +                                    (uintptr_t)image_addr, image_size);
>         } else if (IS_ENABLED(CONFIG_NETDEVICES) && !strcmp(dev, "Net")) {
> -               if (device)
> -                       *device = efi_dp_from_eth();
> +               dp = efi_dp_from_eth();
>         } else if (!strcmp(dev, "Uart")) {
> -               if (device)
> -                       *device = efi_dp_from_uart();
> +               dp = efi_dp_from_uart();
>         } else {
>                 part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
>                                                1);
>                 if (part < 0 || !desc)
>                         return EFI_INVALID_PARAMETER;
>
> -               if (device)
> -                       *device = efi_dp_from_part(desc, part);
> +               dp = efi_dp_from_part(desc, part);
>         }
> +       if (device)
> +               *device = dp;
>
>         if (!path)
>                 return EFI_SUCCESS;
> --
> 2.39.2
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>


More information about the U-Boot mailing list