Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA223C0015E for ; Thu, 27 Jul 2023 03:02:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 058ED867C7; Thu, 27 Jul 2023 05:02:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LYp1JIBN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BC238679C; Thu, 27 Jul 2023 05:01:48 +0200 (CEST) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4757E86785 for ; Thu, 27 Jul 2023 05:01:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-348d1cf5639so1501485ab.3 for ; Wed, 26 Jul 2023 20:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690426903; x=1691031703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6FtKYozU92+63vHpS7z5LgIjLeX0NrCZCd2/rkNx9Tg=; b=LYp1JIBNexbS4Jwglm0USN6oLCgp6kyFLNTtqVyHnLbLVlF4lChi7zzo42Nxh6yPan q668F/n73gM4irEQ+S/odHgcR172tTnSF8Dwj3Dw7MnsrQngJ2wWCj8ti7NcAiKp19PA nPjwVtrswgc6Dg/Z1uOEv/4rAp+bt3e8AG2Wg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690426903; x=1691031703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6FtKYozU92+63vHpS7z5LgIjLeX0NrCZCd2/rkNx9Tg=; b=dTWKvFqQusRNRaNfB/dppZmMHZBWVvJOobylLPHNmUGBZYbjA1yYx9EkMLUhi3D4BG g1BEuMZxABMohLZwiH2S80qGttlG2+gFR0VQqzmCjErK48/s7g2azwYP3xsDHwTLnV4M DCQ6unLFC08ROpoE3kPTSRKRQC39ofkpu9WdOJTg+8O7Rf2uVkOLZ+cmlu/UwlMFqXWu NNC1Frsu4W0NTQ3yz876mUEgEcz3Wp1Hz5wztAcH5O0U0A3pe2pWcmATAWEHjoUGAgEP RFeSe+XM2sMlgragoqKWC47c0yefP4MN9o0FLQSIpgLNtw3ylfA4WGMPh4tdgm0dwNU+ 8kGg== X-Gm-Message-State: ABy/qLZR3PIxJPcRsVtuOXo6NB91443nKs7ruz4iGkV3mlI0ZD2RBVr2 UdfStsTHFiaaKEdm4OzPZJ+JkkiXb4PopxnYpbI= X-Google-Smtp-Source: APBJJlFM6hWW826bA2tHOylAMrQNeD6kXgK+gTkjFReNNYDoiDbCKsbVhP0lbAJUF9uvzpbLocUFcg== X-Received: by 2002:a05:6e02:dcf:b0:348:7ac8:ce6b with SMTP id l15-20020a056e020dcf00b003487ac8ce6bmr3903468ilj.17.1690426902824; Wed, 26 Jul 2023 20:01:42 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id a14-20020a92d58e000000b00348d41ffd13sm207539iln.85.2023.07.26.20.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 20:01:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH 2/5] bootstd: Use a function to detect network in EFI bootmeth Date: Wed, 26 Jul 2023 21:01:22 -0600 Message-ID: <20230727030128.459760-3-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230727030128.459760-1-sjg@chromium.org> References: <20230727030128.459760-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This checks for a network-based bootflow in two places, one of which is less than ideal. Move the correct test into a function and use it in both places. Signed-off-by: Simon Glass --- boot/bootmeth_efi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index af31fbfc85db..e88e171ccc1b 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -94,6 +94,20 @@ static int get_efi_pxe_vci(char *str, int max_len) return 0; } +/** + * bootmeth_uses_network() - check if the media device is Ethernet + * + * @bflow: Bootflow to check + * Returns: true if the media device is Ethernet, else false + */ +static bool bootmeth_uses_network(struct bootflow *bflow) +{ + const struct udevice *media = dev_get_parent(bflow->dev); + + return IS_ENABLED(CONFIG_CMD_DHCP) && + device_get_uclass_id(media) == UCLASS_ETH; +} + static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow) { const struct udevice *media_dev; @@ -354,11 +368,9 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) { - const struct udevice *media = dev_get_parent(bflow->dev); int ret; - if (IS_ENABLED(CONFIG_CMD_DHCP) && - device_get_uclass_id(media) == UCLASS_ETH) { + if (bootmeth_uses_network(bflow)) { /* we only support reading from one device, so ignore 'dev' */ ret = distro_efi_read_bootflow_net(bflow); if (ret) @@ -378,7 +390,7 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) char cmd[50]; /* A non-zero buffer indicates the kernel is there */ - if (bflow->buf) { + if (!bootmeth_uses_network(bflow)) { /* Set the EFI bootdev again, since reading an FDT loses it! */ if (bflow->blk) { struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); -- 2.41.0.487.g6d72f3e995-goog