X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fconsole.c;h=3167921ec9aedd32c34f5191bc441bdecb3b735f;hb=2629a21e209d91cdb778f43612235ed1f3029488;hp=01eef5594fcb146faeac3b4036f6257ce98da36e;hpb=19d1f1a2f3ccfbf85125150f7876ce22714b38bd;p=oweals%2Fu-boot.git diff --git a/common/console.c b/common/console.c index 01eef5594f..3167921ec9 100644 --- a/common/console.c +++ b/common/console.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -146,6 +147,29 @@ static int console_setfile(int file, struct stdio_dev * dev) return error; } +/** + * console_dev_is_serial() - Check if a stdio device is a serial device + * + * @sdev: Device to check + * @return true if this device is in the serial uclass (or for pre-driver-model, + * whether it is called "serial". + */ +static bool console_dev_is_serial(struct stdio_dev *sdev) +{ + bool is_serial; + +#ifdef CONFIG_DM_SERIAL + if (sdev->flags & DEV_FLAGS_DM) { + struct udevice *dev = sdev->priv; + + is_serial = device_get_uclass_id(dev) == UCLASS_SERIAL; + } else +#endif + is_serial = !strcmp(sdev->name, "serial"); + + return is_serial; +} + #if CONFIG_IS_ENABLED(CONSOLE_MUX) /** Console I/O multiplexing *******************************************/ @@ -210,7 +234,7 @@ static void console_puts_noserial(int file, const char *s) for (i = 0; i < cd_count[file]; i++) { dev = console_devices[file][i]; - if (dev->puts != NULL && strcmp(dev->name, "serial") != 0) + if (dev->puts != NULL && !console_dev_is_serial(dev)) dev->puts(dev, s); } } @@ -249,7 +273,7 @@ static inline void console_putc(int file, const char c) static inline void console_puts_noserial(int file, const char *s) { - if (strcmp(stdio_devices[file]->name, "serial") != 0) + if (!console_dev_is_serial(stdio_devices[file])) stdio_devices[file]->puts(stdio_devices[file], s); } @@ -642,7 +666,7 @@ int console_assign(int file, const char *devname) static void console_update_silent(void) { #ifdef CONFIG_SILENT_CONSOLE - if (getenv("silent") != NULL) + if (env_get("silent") != NULL) gd->flags |= GD_FLG_SILENT; else gd->flags &= ~GD_FLG_SILENT; @@ -721,9 +745,9 @@ int console_init_r(void) /* stdin stdout and stderr are in environment */ /* scan for it */ - stdinname = getenv("stdin"); - stdoutname = getenv("stdout"); - stderrname = getenv("stderr"); + stdinname = env_get("stdin"); + stdoutname = env_get("stdout"); + stderrname = env_get("stderr"); if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */ inputdev = search_device(DEV_FLAGS_INPUT, stdinname); @@ -777,7 +801,7 @@ done: #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE /* set the environment variables (will overwrite previous env settings) */ for (i = 0; i < 3; i++) { - setenv(stdio_names[i], stdio_devices[i]->name); + env_set(stdio_names[i], stdio_devices[i]->name); } #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ @@ -812,7 +836,7 @@ int console_init_r(void) * console to serial console in this case or suppress it if * "silent" mode was requested. */ - if (getenv("splashimage") != NULL) { + if (env_get("splashimage") != NULL) { if (!(gd->flags & GD_FLG_SILENT)) outputdev = search_device (DEV_FLAGS_OUTPUT, "serial"); } @@ -856,7 +880,7 @@ int console_init_r(void) /* Setting environment variables */ for (i = 0; i < 3; i++) { - setenv(stdio_names[i], stdio_devices[i]->name); + env_set(stdio_names[i], stdio_devices[i]->name); } gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */