diff options
author | Dawid Niedzwiecki <dn@semihalf.com> | 2021-07-02 08:50:22 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-08 13:22:54 +0000 |
commit | 4b972a220fc1db416c25bd9507e03f66156ab29f (patch) | |
tree | 5cf52060fb446cc0011d01cebdfa2dc28e763403 /common | |
parent | e32d244db05fc5fb4f2d3643418282c668d6fd45 (diff) | |
download | chrome-ec-4b972a220fc1db416c25bd9507e03f66156ab29f.tar.gz |
console: use functions to check console channels
Create a function to check if a console channel is disabled.
It allows checking a channel outside the console_output.c, which is
needed in Zephyr.
BUG=b:191724484
BRANCH=none
TEST=Check if console channels works
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I9ab38c17c66373c3a38f45c8080c8166a2a9d09f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3001270
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/console_output.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/common/console_output.c b/common/console_output.c index 237c45cba6..aa7a558bf7 100644 --- a/common/console_output.c +++ b/common/console_output.c @@ -63,6 +63,13 @@ void console_channel_disable(const char *name) if (index >= 0 && index != CC_COMMAND) channel_mask &= ~CC_MASK(index); } + +bool console_channel_is_disabled(enum console_channel channel) +{ + if (!(CC_MASK(channel) & channel_mask)) + return true; + return false; +} #endif /* CONFIG_CONSOLE_CHANNEL */ /*****************************************************************************/ @@ -72,11 +79,9 @@ int cputs(enum console_channel channel, const char *outstr) { int rv1, rv2; -#ifdef CONFIG_CONSOLE_CHANNEL /* Filter out inactive channels */ - if (!(CC_MASK(channel) & channel_mask)) + if (console_channel_is_disabled(channel)) return EC_SUCCESS; -#endif rv1 = usb_puts(outstr); rv2 = uart_puts(outstr); @@ -89,11 +94,9 @@ int cprintf(enum console_channel channel, const char *format, ...) int rv1, rv2; va_list args; -#ifdef CONFIG_CONSOLE_CHANNEL /* Filter out inactive channels */ - if (!(CC_MASK(channel) & channel_mask)) + if (console_channel_is_disabled(channel)) return EC_SUCCESS; -#endif usb_va_start(args, format); rv1 = usb_vprintf(format, args); @@ -111,11 +114,9 @@ int cprints(enum console_channel channel, const char *format, ...) int r, rv; va_list args; -#ifdef CONFIG_CONSOLE_CHANNEL /* Filter out inactive channels */ - if (!(CC_MASK(channel) & channel_mask)) + if (console_channel_is_disabled(channel)) return EC_SUCCESS; -#endif rv = cprintf(channel, "[%pT ", PRINTF_TIMESTAMP_NOW); |