From patchwork Sat May 13 08:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1780916 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=hykQVWTR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QJK7j2Krpz20KG for ; Sat, 13 May 2023 18:49:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F1B58631D; Sat, 13 May 2023 10:48:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="hykQVWTR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2763D85FEF; Sat, 13 May 2023 10:48:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1623284702 for ; Sat, 13 May 2023 10:48:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.fritz.box (ip-088-152-145-137.um26.pools.vodafone-ip.de [88.152.145.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 839634125E; Sat, 13 May 2023 08:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1683967715; bh=aZoOUTbGXv/WwV2TiqASPhLESom88WRDoluPf3RCGj8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hykQVWTRiOqQbxFBaVEngJiUrUQodqsGjCUMRsMJK3ei3A2GWoJzazxGoZZyxtfdG PB5H58OAQdc4z0hVNiSL5FPGqAp+mGYA0EmJdokc/uXdnVV9IEAThZLInSKMCWyHks A1OoYCA7krphZAVGHJGC/2XPKqU0FxdJ+V++NdEz4DZu4tDVS2jqpI9vYNBYPsbUJm sCjm5I8zzmL7PQoOCKGwe9XYt2fB0fz4409tIg2q6sW8cAGUC++myMI2c7wuIt8RmH Lah0KnlmGHuU4IoSABdCut+H7cZalZi0bnAeaCYBNm4Y6iK2/TW+gF9FrV5snR7w4k nHW91UHzMMbFg== From: Heinrich Schuchardt To: Ilias Apalodimas Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 5/6] efi_loader: simplify efi_dp_from_name() Date: Sat, 13 May 2023 10:48:19 +0200 Message-Id: <20230513084820.38625-6-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230513084820.38625-1-heinrich.schuchardt@canonical.com> References: <20230513084820.38625-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Don't do the same check and assignment in multiple places. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- 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;