diff options
author | Simon Glass <sjg@chromium.org> | 2017-07-27 09:31:03 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-07-31 12:21:40 -0400 |
commit | 42f9f915c2b7aeac222c93a7f7085d9838722efc (patch) | |
tree | 0c0467f492b69fa9aff8db01034af8bc6b060cdb /common | |
parent | ef3fc42ded96403284e5e9bf37b63d332aedd7b4 (diff) | |
download | u-boot-42f9f915c2b7aeac222c93a7f7085d9838722efc.tar.gz u-boot-42f9f915c2b7aeac222c93a7f7085d9838722efc.tar.bz2 u-boot-42f9f915c2b7aeac222c93a7f7085d9838722efc.zip |
console: Unify the check for a serial console
Put the check for whether a console is a serial device in a function so
that we can share the code in the two places that use it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/console.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/common/console.c b/common/console.c index 01eef5594f..b7ed9a3b9d 100644 --- a/common/console.c +++ b/common/console.c @@ -146,6 +146,21 @@ 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 a serial device + */ +static bool console_dev_is_serial(struct stdio_dev *sdev) +{ + bool is_serial; + + is_serial = !strcmp(sdev->name, "serial"); + + return is_serial; +} + #if CONFIG_IS_ENABLED(CONSOLE_MUX) /** Console I/O multiplexing *******************************************/ @@ -210,7 +225,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 +264,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); } |