diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-01-19 13:33:21 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-22 18:50:11 -0800 |
commit | c06d7fea8f6b8235e9a7dcbb76e2a637189f9d2e (patch) | |
tree | 35a1b5a2f1d01a08bacf567d8b6506778858bcab /common/host_command.c | |
parent | d9f4ce13f2a49a260db7bb6d42234439184e9e55 (diff) | |
download | chrome-ec-c06d7fea8f6b8235e9a7dcbb76e2a637189f9d2e.tar.gz |
host_command: Suppress individual host command debug log
Host command handler prints every single host command except when
commands are repeated back-to-back. This patch allows each board
decide which commands should be ignored. When debug printf is
suppressed, a global counter is incremented. Developers know there
were commands processed but not reported to the console.
BUG=chromium:803955
BRANCH=none
TEST=Observe 0x97 and 0x98 were not printed. Global suppress
counter is incremented.
Change-Id: I05e8cde9039f602e8fc06c20e89b328e797bd733
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/876952
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r-- | common/host_command.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/common/host_command.c b/common/host_command.c index bd397a6616..3de9c27850 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -560,6 +560,22 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_CMD_VERSIONS, host_command_get_cmd_versions, EC_VER_MASK(0) | EC_VER_MASK(1)); +extern uint16_t host_command_suppressed[]; +/* Default suppress list. Define yours in board.c. */ +static uint32_t suppressed_count; + +static int host_command_is_suppressed(uint16_t cmd) +{ +#ifdef CONFIG_SUPPRESS_HOST_COMMANDS + uint16_t *p = host_command_suppressed; + while (*p != HOST_COMMAND_SUPPRESS_DELIMITER) { + if (*p++ == cmd) + return 1; + } +#endif + return 0; +} + /** * Print debug output for the host command request, before it's processed. * @@ -578,6 +594,10 @@ static void host_command_debug_request(struct host_cmd_handler_args *args) */ if (hcdebug == HCDEBUG_NORMAL) { uint64_t t = get_time().val; + if (host_command_is_suppressed(args->command)) { + suppressed_count++; + return; + } if (args->command == hc_prev_cmd && t - hc_prev_time < HCDEBUG_MAX_REPEAT_DELAY) { hc_prev_count++; @@ -846,6 +866,7 @@ static int command_hcdebug(int argc, char **argv) ccprintf("Host command debug mode is %s\n", hcdebug_mode_names[hcdebug]); + ccprintf("%u suppressed\n", suppressed_count); return EC_SUCCESS; } |