From patchwork Wed Oct 29 06:16:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 646 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718643; bh=8z8LjT2bWFrG9pJZcciUQJpqhji9vYP92XmKr+O7VMA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Nlukr+4pdnd8pRJzOQEx0BJ0EKPf3eB2+8a3zvnSmQ3+xiZgHLWV7w3p2JKdHDXT1 hG5V8zZufpWc6MArXfh4mWgUWHBoFUTzxlgBiD5SlFRvXaVWiwyiLijxa6U7MxiqYV mEJAEHTWlhyZcxzZddDp2B/p+jxDFUmyMq3uwWS1hRJuXyLkSfWt1ffuWpgjLAxQ0P Fm10tj3zXKVavSpOdHfotuM4kEvniqBmTpJefSdwGgPjcle7AjrTohTLgV+agDG3ve hA6EQdTPoED0HvtoNSLHZgJwbE+5q6Hjfvj3JpmFXkEIKfKz1vVLvZQZGeMBxu56L1 30eHqecpFqYEw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DDE496824C for ; Wed, 29 Oct 2025 00:17:23 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id WGXBQbmEM2AO for ; Wed, 29 Oct 2025 00:17:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718643; bh=8z8LjT2bWFrG9pJZcciUQJpqhji9vYP92XmKr+O7VMA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Nlukr+4pdnd8pRJzOQEx0BJ0EKPf3eB2+8a3zvnSmQ3+xiZgHLWV7w3p2JKdHDXT1 hG5V8zZufpWc6MArXfh4mWgUWHBoFUTzxlgBiD5SlFRvXaVWiwyiLijxa6U7MxiqYV mEJAEHTWlhyZcxzZddDp2B/p+jxDFUmyMq3uwWS1hRJuXyLkSfWt1ffuWpgjLAxQ0P Fm10tj3zXKVavSpOdHfotuM4kEvniqBmTpJefSdwGgPjcle7AjrTohTLgV+agDG3ve hA6EQdTPoED0HvtoNSLHZgJwbE+5q6Hjfvj3JpmFXkEIKfKz1vVLvZQZGeMBxu56L1 30eHqecpFqYEw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDCE2682B7 for ; Wed, 29 Oct 2025 00:17:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718642; bh=XUnLw7WkZfm2btsOCFOxxdDRjED7PvLX0YptHOTLHvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ljBW+5S5IbDwISSWXwTfqluM1xmGcy0M+1UM/g1Q1K1tk9v1RZIiEFJZ9M9WiEBVG L/l7cfHHP1G6VY3rhbyzTzSDh0NPz5cL7VzzbEvDg0tBuP0rq9ovSkakRHZhxk4Zqu W59blwv9Hjesj25C3h1aqU0IK2DQIA+XgHM7zF7R6zfmR8o/nv7ebX6QqpbMQgOOGI pTC991qfLNPo3Lw30tmfWBAmgdtqzWO33mZ9qTCPQBOm2C42S78Qu9iv3YSIN7d0Xl iqx+TlXfP2hMl8UvbKxohDesFLZO46QqGachdE0vpoA9T/L3y6EMsEBxMXb6WDdLfP GaXAbzWaHkc8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0521968303; Wed, 29 Oct 2025 00:17:22 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id g1wwhGk8A65o; Wed, 29 Oct 2025 00:17:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718638; bh=uCT/wQ0g1xCM+z6DyX5lgwLtrkGJs6QV3DazkmdFQ2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TYyupsEGxUvsX+AIzqOZv5vK57tx6x/k9w7T0oPAaMhY9nstv6BNSfGitnVs4LMtT AUlmC7oJ80arOKbZFtchBTzJOx/hs/EM9YODXWds6HaA4oBucKyICqlLZTavnefGFN 03wo9JM8ZJYIbTBwyTA5s96VN99eFO/Z6XDZ4vh7T//sORYeuLjgfiGU/mdOAsePWs YohnQhsJRLHOZTswefqtlcP0PwG/PWW5q4KMtnGZw/uBH0sJGrR9G9+32JRcv4zylC STl1H9RAC06N/A31M+DFfuo8+YM2cQA+PtJV1D8ZA15LiHia0IJqDshvA9rmnKZ6f/ 7e6jKDHTpcsEA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AFE5D682D9; Wed, 29 Oct 2025 00:17:17 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 29 Oct 2025 00:16:44 -0600 Message-ID: <20251029061657.1456910-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251029061657.1456910-1-sjg@u-boot.org> References: <20251029061657.1456910-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZCM4DQC5S57T2IOY7VAX2FJGKQW5LZHH X-Message-ID-Hash: ZCM4DQC5S57T2IOY7VAX2FJGKQW5LZHH X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 2/7] qfw: Silence the message when opt/u-boot/bootcmd is not found List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Currently qfw_locate_file() always prints error messages when it can't find a file. This causes unwanted error output in qemu_get_bootcmd() when the optional "opt/u-boot/bootcmd" file doesn't exist. Adjust qfw_locate_file() to be silent, with a new qfw_locate_file_msg() that shows messages. This allows callers to choose whether missing files should generate error messages. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/qfw/qfw.c | 26 ++++++++++++++++++-------- include/qfw.h | 20 +++++++++++++++++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/qfw/qfw.c b/drivers/qfw/qfw.c index 2e260d60449..51f25b9ff0b 100644 --- a/drivers/qfw/qfw.c +++ b/drivers/qfw/qfw.c @@ -220,16 +220,12 @@ int qfw_locate_file(struct udevice *dev, const char *fname, /* make sure fw_list is loaded */ ret = qfw_read_firmware_list(dev); - if (ret) { - printf("error: can't read firmware file list\n"); + if (ret) return -EINVAL; - } file = qfw_find_file(dev, fname); - if (!file) { - printf("error: can't find %s\n", fname); + if (!file) return -ENOENT; - } *selectp = be16_to_cpu(file->cfg.select); *sizep = be32_to_cpu(file->cfg.size); @@ -237,13 +233,27 @@ int qfw_locate_file(struct udevice *dev, const char *fname, return 0; } +int qfw_locate_file_msg(struct udevice *dev, const char *fname, + enum fw_cfg_selector *selectp, ulong *sizep) +{ + int ret; + + ret = qfw_locate_file(dev, fname, selectp, sizep); + if (ret == -EINVAL) + printf("error: can't read firmware file list\n"); + else if (ret == -ENOENT) + printf("error: can't find %s\n", fname); + + return ret; +} + int qfw_load_file(struct udevice *dev, const char *fname, ulong addr) { enum fw_cfg_selector select; ulong size; int ret; - ret = qfw_locate_file(dev, fname, &select, &size); + ret = qfw_locate_file_msg(dev, fname, &select, &size); if (ret) return ret; @@ -258,7 +268,7 @@ int qfw_get_file(struct udevice *dev, const char *fname, struct abuf *loader) ulong size; int ret; - ret = qfw_locate_file(dev, fname, &select, &size); + ret = qfw_locate_file_msg(dev, fname, &select, &size); if (ret) return ret; diff --git a/include/qfw.h b/include/qfw.h index 75aada09206..1a634d7ed5d 100644 --- a/include/qfw.h +++ b/include/qfw.h @@ -467,15 +467,33 @@ int qfw_get_file(struct udevice *dev, const char *fname, struct abuf *loader); /** * qfw_locate_file() - Locate a file in the QEMU firmware config * + * This is the silent version that doesn't print error messages + * * @dev: UCLASS_QFW device * @fname: Filename to locate * @selectp: Returns the selector for the file * @sizep: Returns the size of the file - * Return: 0 on success, -EINVAL if firmware list cannot be read or file not found + * Return: 0 on success, -EINVAL if firmware list cannot be read, -ENOENT if + * file not found */ int qfw_locate_file(struct udevice *dev, const char *fname, enum fw_cfg_selector *selectp, ulong *sizep); +/** + * qfw_locate_file_msg() - Locate a file in the QEMU firmware config + * + * This version prints error messages on failure + * + * @dev: UCLASS_QFW device + * @fname: Filename to locate + * @selectp: Returns the selector for the file + * @sizep: Returns the size of the file + * Return: 0 on success, -EINVAL if firmware list cannot be read, -ENOENT if + * file not found + */ +int qfw_locate_file_msg(struct udevice *dev, const char *fname, + enum fw_cfg_selector *selectp, ulong *sizep); + /** * cmd_qfw_e820() - Execute the 'qfw e820' command for x86 *