From mboxrd@z Thu Jan 1 00:00:00 1970 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 96FB9C6FD1D for ; Sun, 2 Apr 2023 02:04:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A01785DD1; Sun, 2 Apr 2023 04:03:54 +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="I+/tLrDw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 690CB85D63; Sun, 2 Apr 2023 04:03:28 +0200 (CEST) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 6211E80ADE for ; Sun, 2 Apr 2023 04:03:17 +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-pl1-x62d.google.com with SMTP id z19so24983061plo.2 for ; Sat, 01 Apr 2023 19:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1680400995; 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=lwJYc45uswBgcTNSDjw+6FVqF6I9eTkKEb/74S6X++U=; b=I+/tLrDwYZnzUc2HhY7kbF7hZflEsl+xb94Aqr/pOI0U1sid4UPTp1sEKfB809OiVt 8avxSCsz17gNWnRnpL0YxI/llfuat+oAr1xL44RGV69ZEVARCuBaiZrBgnVpgaxIx+st insB0VRAO4V0NSSEDG0FtmEKPGArY41sHDEdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680400995; 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=lwJYc45uswBgcTNSDjw+6FVqF6I9eTkKEb/74S6X++U=; b=QNcbDIOrUbtG3drX+ZIg/aCQfiN3MuEuiWihspBa2fgK8ZbTBVNpg76n1lgK+5UKAY 3mr8TuigO7mkGI12Bx6YubMzjPDgYPhARysuLZHtJPZSvjo8seuKUR4Rpa8fphUPuDLJ nZsGvibmIalyrTCz6ao7RGS0YDAvYvxB5FD0qkDN2GbLXeWRYSMqvSA7L2F7/h7J8ZVS eOF7M1RE2x9FAQDHXTg+fMnpVZ59oLXUZveRMzKUC3rc3W5Glpcyof4mLeYWw34aKxna Oe82+4yRXdpGlE3VVDw827bNzt+EMN9EDmTm6OXmcgz1Bj/tu1VxRtS4IljzcqTJP2E6 XzKg== X-Gm-Message-State: AAQBX9fr9vylP2ZMMIQ7m78e1NOww1AxWb/OgnmHW1EtxVMa2ii2/2yL 4c9yHfPBA6Z0vzCQ7vRuZlot+h1L4p8IfrPOwIs= X-Google-Smtp-Source: AKy350ZQVgQZwBrRUnPV+9EYGdF2R4y8x4fkv+DTUFTR/c+TJK1g2LtE21FrBbh9ocVcfPKaggR7Jw== X-Received: by 2002:a17:902:e414:b0:19e:e39b:6da2 with SMTP id m20-20020a170902e41400b0019ee39b6da2mr25567087ple.29.1680400995202; Sat, 01 Apr 2023 19:03:15 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b0019b0937003esm3988380plq.150.2023.04.01.19.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 19:03:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mark Kettenis , huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Tom Rini , Vagrant Cascadian Subject: [PATCH v7 04/11] bootstd: Report missing labels only when asked Date: Sun, 2 Apr 2023 14:02:26 +1200 Message-Id: <20230402140231.v7.4.I34e1ec50c59a5a2427c692f612cd2cfa8d30d325@changeid> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog In-Reply-To: <20230402140231.v7.1.Id5a4b4ee7b653591dfb25e75204c17215521164b@changeid> References: <20230402140231.v7.1.Id5a4b4ee7b653591dfb25e75204c17215521164b@changeid> 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 Use the -l flag to indicate whether to report missing uclasses. Also try to be more helpful when no devices are found. For example, when we see something 'scsi0' requested and nothing was found, this indicates that there are no SCSI devices, so show a suitable message. Move messages out of the low-level functions so that silent operation is possible. This means they are never reported unless BOOTSTD_FULL is enabled, since the -l flag cannot otherwise be set. Suggested-by: Tom Rini Signed-off-by: Simon Glass --- (no changes since v6) Changes in v6: - Add new patch to report missing labels only when asked boot/bootdev-uclass.c | 32 +++++++++++++++++++++++++------- include/bootdev.h | 2 +- test/boot/bootdev.c | 12 +++++------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index d34b7e37cf79..91087981d213 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -364,7 +364,8 @@ int bootdev_unbind_dev(struct udevice *parent) * @seqp: Returns the sequence number, or -1 if none * @method_flagsp: If non-NULL, returns any flags implied by the label * (enum bootflow_meth_flags_t), 0 if none - * Returns: sequence number on success, else -ve error code + * Returns: sequence number on success, -EPFNOSUPPORT is the uclass is not + * known, other -ve error code on other error */ static int label_to_uclass(const char *label, int *seqp, int *method_flagsp) { @@ -394,8 +395,7 @@ static int label_to_uclass(const char *label, int *seqp, int *method_flagsp) id = UCLASS_ETH; method_flags |= BOOTFLOW_METHF_DHCP_ONLY; } else { - log_warning("Unknown uclass '%s' in label\n", label); - return -EINVAL; + return -EPFNOSUPPORT; } } if (id == UCLASS_USB) @@ -458,7 +458,6 @@ int bootdev_find_by_label(const char *label, struct udevice **devp, } log_debug("- no device in %s\n", media->name); } - log_warning("Unknown seq %d for label '%s'\n", seq, label); return -ENOENT; } @@ -577,9 +576,28 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, log_debug("next\n"); for (dev = NULL; !dev && iter->labels[++iter->cur_label];) { - log_debug("Scanning: %s\n", iter->labels[iter->cur_label]); - bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label], - &dev, method_flagsp); + const char *label = iter->labels[iter->cur_label]; + int ret; + + log_debug("Scanning: %s\n", label); + ret = bootdev_hunt_and_find_by_label(label, &dev, + method_flagsp); + if (iter->flags & BOOTFLOWIF_SHOW) { + if (ret == -EPFNOSUPPORT) { + log_warning("Unknown uclass '%s' in label\n", + label); + } else if (ret == -ENOENT) { + /* + * looking for, e.g. 'scsi0' should find + * something if SCSI is present + */ + if (!trailing_strtol(label)) { + log_warning("No bootdevs for '%s'\n", + label); + } + } + } + } if (!dev) diff --git a/include/bootdev.h b/include/bootdev.h index b92ff4d4f154..e72ef3650f7c 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -258,7 +258,7 @@ int bootdev_find_by_label(const char *label, struct udevice **devp, * @devp: returns the device found, on success * @method_flagsp: If non-NULL, returns any flags implied by the label * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails - * Return: 0 if OK, -EINVAL if the uclass is not supported by this board, + * Return: 0 if OK, -EPFNOSUPPORT if the uclass is not supported by this board, * -ENOENT if there is no device with that number */ int bootdev_find_by_any(const char *name, struct udevice **devp, diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 4fe9fd722084..0899c78c2c4a 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -124,7 +124,8 @@ static int bootdev_test_labels(struct unit_test_state *uts) mflags); /* Check invalid uclass */ - ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev, &mflags)); + ut_asserteq(-EPFNOSUPPORT, + bootdev_find_by_label("fred0", &dev, &mflags)); /* Check unknown sequence number */ ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev, &mflags)); @@ -179,9 +180,8 @@ static int bootdev_test_any(struct unit_test_state *uts) /* Check invalid uclass */ mflags = 123; - ut_asserteq(-EINVAL, bootdev_find_by_any("fred0", &dev, &mflags)); - ut_assert_nextline("Unknown uclass 'fred0' in label"); - ut_assert_nextline("Cannot find bootdev 'fred0' (err=-22)"); + ut_asserteq(-EPFNOSUPPORT, bootdev_find_by_any("fred0", &dev, &mflags)); + ut_assert_nextline("Cannot find bootdev 'fred0' (err=-96)"); ut_asserteq(123, mflags); ut_assert_console_end(); @@ -512,9 +512,8 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts) old = (void *)&mflags; /* arbitrary pointer to check against dev */ dev = old; mflags = 123; - ut_asserteq(-EINVAL, + ut_asserteq(-EPFNOSUPPORT, bootdev_hunt_and_find_by_label("fred", &dev, &mflags)); - ut_assert_nextline("Unknown uclass 'fred' in label"); ut_asserteq_ptr(old, dev); ut_asserteq(123, mflags); ut_assert_console_end(); @@ -525,7 +524,6 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts) bootdev_hunt_and_find_by_label("mmc4", &dev, &mflags)); ut_asserteq_ptr(old, dev); ut_asserteq(123, mflags); - ut_assert_nextline("Unknown seq 4 for label 'mmc4'"); ut_assert_console_end(); ut_assertok(bootstd_test_check_mmc_hunter(uts)); -- 2.40.0.348.gf938b09366-goog