
From: Simon Glass <sjg@chromium.org> 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 <sjg@chromium.org> --- (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 <command.h> +#include <dm.h> #include <iomux.h> #include <stdio_dev.h> +/* 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; -- 2.43.0