console: Update conio command to show uclass
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>
This commit is contained in:
@@ -175,6 +175,14 @@ config CMD_CONSOLE
|
|||||||
help
|
help
|
||||||
Print console devices and information.
|
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
|
config CMD_CPU
|
||||||
bool "cpu"
|
bool "cpu"
|
||||||
depends on CPU
|
depends on CPU
|
||||||
|
|||||||
@@ -8,9 +8,17 @@
|
|||||||
* Boot support
|
* Boot support
|
||||||
*/
|
*/
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <dm.h>
|
||||||
#include <iomux.h>
|
#include <iomux.h>
|
||||||
#include <stdio_dev.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,
|
static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
@@ -20,17 +28,32 @@ static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc,
|
|||||||
struct stdio_dev *sdev;
|
struct stdio_dev *sdev;
|
||||||
|
|
||||||
/* Scan for valid output and input devices */
|
/* Scan for valid output and input devices */
|
||||||
|
puts("List of available devices\n\n");
|
||||||
puts("List of available devices\n");
|
if (IS_ENABLED(CONFIG_CMD_CONSOLE_EXTRA))
|
||||||
|
puts("Device File Uclass\n");
|
||||||
|
|
||||||
list_for_each(pos, list) {
|
list_for_each(pos, list) {
|
||||||
sdev = list_entry(pos, struct stdio_dev, list);
|
sdev = list_entry(pos, struct stdio_dev, list);
|
||||||
|
|
||||||
printf("|-- %s (%s%s)\n",
|
printf("|-- %s (%s%s)" USE_NL,
|
||||||
sdev->name,
|
sdev->name,
|
||||||
(sdev->flags & DEV_FLAGS_INPUT) ? "I" : "",
|
(sdev->flags & DEV_FLAGS_INPUT) ? "I" : "",
|
||||||
(sdev->flags & DEV_FLAGS_OUTPUT) ? "O" : "");
|
(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++) {
|
for (l = 0; l < MAX_FILES; l++) {
|
||||||
if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
|
if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
|
||||||
if (iomux_match_device(console_devices[l],
|
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)
|
if (stdio_devices[l] == sdev)
|
||||||
printf("| |-- %s\n", stdio_names[l]);
|
printf("| |-- %s\n", stdio_names[l]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user