From patchwork Mon Aug 25 16:27:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 132 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=1756139274; bh=nP6fwrVzUVIjbGqocg+krxz2BxWOUgIYFWc7rzcvkM8=; 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=V4O25p7RxSJnuhtNu4EOThuj29rpH9TDamTUFnogSHbZPJttJwJbazkJ8DYvd380Y iBmpWKPcpEFV8G2CAhTvQXUxJAAZCz2l6k7CrY505hYR4Jj0fxyKyDWT6PBZ+3LXH2 BuuA2EgN/CIQBENe9sTySwtmkgcKqJZZMY7NjKi8RO5A5KLGjbB8MUYhXrRFDRjMkt M05ESNIR/gD1MmGWcasdOIdpV1vDmNQ4hU2EnTAjhMSonyoT+/UWuyEggpD7xieWLC CumaetKp/9D0P1E0msi3bbop4ei0sF8Dxx+RWJ9ZujmZvYxL+7IVeyfgJVq/W6buH3 ok2Lj/no+MCOg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D00EE67706 for ; Mon, 25 Aug 2025 10:27:54 -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 R8wapiXqxLac for ; Mon, 25 Aug 2025 10:27:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139274; bh=nP6fwrVzUVIjbGqocg+krxz2BxWOUgIYFWc7rzcvkM8=; 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=V4O25p7RxSJnuhtNu4EOThuj29rpH9TDamTUFnogSHbZPJttJwJbazkJ8DYvd380Y iBmpWKPcpEFV8G2CAhTvQXUxJAAZCz2l6k7CrY505hYR4Jj0fxyKyDWT6PBZ+3LXH2 BuuA2EgN/CIQBENe9sTySwtmkgcKqJZZMY7NjKi8RO5A5KLGjbB8MUYhXrRFDRjMkt M05ESNIR/gD1MmGWcasdOIdpV1vDmNQ4hU2EnTAjhMSonyoT+/UWuyEggpD7xieWLC CumaetKp/9D0P1E0msi3bbop4ei0sF8Dxx+RWJ9ZujmZvYxL+7IVeyfgJVq/W6buH3 ok2Lj/no+MCOg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 55C106778A for ; Mon, 25 Aug 2025 10:27:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139269; bh=Du4X6Je97QJCADCmCYmSZY2N9pUExc5XCqvD3FHzJYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKia1U4xVTiFoXhWCAHVyHKCYmK9kX/LmRGDMtHTYGUDIsJt7A1Rgdm6KoiHIMF35 0eNndx7gNyDPaifT2w/GxydgjL7f0s6RG+bFEfHxvDUKuyaI7T7jxG+9lcmsMTzHLj m1Ssqry5XcGTQUNNHYUQ50aFen2VQAPVZxc7d2RaPqsTM1Pdvi9tv3XZ/h4Kas3Wqj D4kR90o0QiiO2Inb3Vn9eVHSF0U2N0L5eAkoj1hrWgCiakvuWO1UHUjp9P4+PdFZ/6 afani+u/1qxDABxCP3JuoGR/YF/ZBaQ3i8MWXtTKu/2dJl0bZ1TWcKufGWgCyOT7zq 86mtQIfFXUzfg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 08EDB6779C; Mon, 25 Aug 2025 10:27:49 -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 PzeRDrCLKjRB; Mon, 25 Aug 2025 10:27:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139267; bh=8jM5eQwWL9ja7bXg7xlbKojytHZWju+MaPNU5QGjFdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wZXyb8uUotoQC7LAoJgwXKMbMu79OK1q6mjFrDsKzZC4ZiVzAzQ1/c8OOIzkmZhxK waMgVfP5+odHnYwOh/L5Xdi3eccY4pBV2B5I/KzikhH3fyhGvctlsc6gN8PtKDuglr 6CM9ziFZiGKVaDbqGQETUHXpdwITYtwgz9H2/0sdPuy5lHVmJ21z/wbsfMfxRt4keU cB1HEs/EcHeD90VpJ6GgTA7IY0c9g10q50IU5g/kkTbSz4XxMxr/l0yD/x2WiWZ74M hXde72gU10kL/6LKFYlkpkoQmh4JWJmCWWt47rfWZeHcFkiq1x1LDx6AsaB0cG4aSF yEOaY8uZ1llkA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 15AB567791; Mon, 25 Aug 2025 10:27:47 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 10:27:14 -0600 Message-ID: <20250825162727.3185381-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825162727.3185381-1-sjg@u-boot.org> References: <20250825162727.3185381-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ABOR3ZCITJUVDLAYAJVZUAASVEVIY3L6 X-Message-ID-Hash: ABOR3ZCITJUVDLAYAJVZUAASVEVIY3L6 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 11/16] console: Update conio command to show uclass 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 When an stdio device is provided by a driver model device, optionally show the uclass. Be careful to avoid increasing code size, since this is a common command. Signed-off-by: Simon Glass --- (no changes since v1) cmd/Kconfig | 8 ++++++++ cmd/console.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 882a4ee02e3..99101ff6c82 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -175,6 +175,14 @@ config CMD_CONSOLE help Print console devices and information. +config CMD_CONSOLE_EXTRA + bool "Show uclass for driver model devices" + default y if SANDBOX + help + Expands the coninfo command to show the uclass for all stdio devices + which are provided by a driver model device. This increase code size + by about 200 bytes. + config CMD_CPU bool "cpu" depends on CPU diff --git a/cmd/console.c b/cmd/console.c index cb0c041d947..a9940467dbd 100644 --- a/cmd/console.c +++ b/cmd/console.c @@ -8,9 +8,17 @@ * Boot support */ #include +#include #include #include +/* shenangans to avoid code-size increase */ +#ifdef CONFIG_CMD_CONSOLE_EXTRA +#define USE_NL "" +#else +#define USE_NL "\n" +#endif + static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc, char *const argv[]) { @@ -20,17 +28,32 @@ static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc, struct stdio_dev *sdev; /* Scan for valid output and input devices */ - - puts("List of available devices\n"); + puts("List of available devices\n\n"); + if (IS_ENABLED(CONFIG_CMD_CONSOLE_EXTRA)) + puts("Device File Uclass\n"); list_for_each(pos, list) { sdev = list_entry(pos, struct stdio_dev, list); - printf("|-- %s (%s%s)\n", + printf("|-- %s (%s%s)" USE_NL, sdev->name, (sdev->flags & DEV_FLAGS_INPUT) ? "I" : "", (sdev->flags & DEV_FLAGS_OUTPUT) ? "O" : ""); + if (IS_ENABLED(CONFIG_CMD_CONSOLE_EXTRA) && + IS_ENABLED(CONFIG_DM_STDIO) && + (sdev->flags & DEV_FLAGS_DM)) { + struct udevice *dev = sdev->priv; + int len = 0; + + len += (sdev->flags & DEV_FLAGS_INPUT) != 0; + len += (sdev->flags & DEV_FLAGS_OUTPUT) != 0; + printf("%*s%s", 20 - len - (int)strlen(sdev->name), "", + dev_get_uclass_name(dev)); + } + if (IS_ENABLED(CONFIG_CMD_CONSOLE_EXTRA)) + puts("\n"); + for (l = 0; l < MAX_FILES; l++) { if (CONFIG_IS_ENABLED(CONSOLE_MUX)) { if (iomux_match_device(console_devices[l], @@ -40,7 +63,6 @@ static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc, if (stdio_devices[l] == sdev) printf("| |-- %s\n", stdio_names[l]); } - } } return 0;