[PATCH 1/1] cmd: improve coninfo output formatting

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Sat Jan 28 01:11:56 CET 2023


Device name are typically longer than 8 characters. This leads to ragged
output.
Only the I and O bit of the device flags are of interest for the user.
Writing a hexadecimal number is just confusing.

Before the patch the output looked like this:

    => coninfo
    List of available devices:
    pl011 at 9000000 00000007 IO stdin stdout stderr
    serial   00000003 IO
    usbkbd   00000001 I.

With the patch the output looks like this:

    => coninfo
    List of available devices
    |-- pl011 at 9000000 (IO)
    |   |-- stdin
    |   |-- stdout
    |   |-- stderr
    |-- serial (IO)
    |-- usbkbd (I)

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 cmd/console.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/cmd/console.c b/cmd/console.c
index 9a1db83c7c..620a961cde 100644
--- a/cmd/console.c
+++ b/cmd/console.c
@@ -22,23 +22,21 @@ static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc,
 
 	/* Scan for valid output and input devices */
 
-	puts ("List of available devices:\n");
+	puts("List of available devices\n");
 
 	list_for_each(pos, list) {
 		dev = list_entry(pos, struct stdio_dev, list);
 
-		printf ("%-8s %08x %c%c ",
-			dev->name,
-			dev->flags,
-			(dev->flags & DEV_FLAGS_INPUT) ? 'I' : '.',
-			(dev->flags & DEV_FLAGS_OUTPUT) ? 'O' : '.');
+		printf("|-- %s (%s%s)\n",
+		       dev->name,
+		       (dev->flags & DEV_FLAGS_INPUT) ? "I" : "",
+		       (dev->flags & DEV_FLAGS_OUTPUT) ? "O" : "");
 
 		for (l = 0; l < MAX_FILES; l++) {
 			if (stdio_devices[l] == dev) {
-				printf ("%s ", stdio_names[l]);
+				printf("|   |-- %s\n", stdio_names[l]);
 			}
 		}
-		putc ('\n');
 	}
 	return 0;
 }
-- 
2.38.1



More information about the U-Boot mailing list