diff options
author | Keith Short <keithshort@chromium.org> | 2021-08-10 09:28:53 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-18 23:45:56 +0000 |
commit | f78eee4550dc747b558c1dfc333ba9b629216f39 (patch) | |
tree | d45ae776137eb559cbb021e8eff7a62738bc4a57 /zephyr/shim/src | |
parent | 110f908a498551a9f90d86d8b5dd369acdf98438 (diff) | |
download | chrome-ec-f78eee4550dc747b558c1dfc333ba9b629216f39.tar.gz |
zephyr: reduce code duplication of console shim
Change the console command shim to pass in a struct, reducing the amount
of duplicated code.
This change saves 500 bytes on Volteer
BUG=none
BRANCH=none
TEST=zmake testall
TEST=verify console on Volteer
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I2da374b9a3b3b78a3e7b66d5c31f4ed2131aef01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3093491
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r-- | zephyr/shim/src/console.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c index 17797fb991..929f7a9d1c 100644 --- a/zephyr/shim/src/console.c +++ b/zephyr/shim/src/console.c @@ -18,6 +18,7 @@ #include "printf.h" #include "uart.h" #include "usb_console.h" +#include "zephyr_console_shim.h" LOG_MODULE_REGISTER(shim_console, LOG_LEVEL_ERR); @@ -160,26 +161,22 @@ void uart_shell_start(void) k_poll(&event, 1, K_FOREVER); } -int zshim_run_ec_console_command(int (*handler)(int argc, char **argv), - const struct shell *shell, size_t argc, - char **argv, const char *help_str, - const char *argdesc) +int zshim_run_ec_console_command(const struct zephyr_console_command *command, + size_t argc, char **argv) { - ARG_UNUSED(shell); - for (int i = 1; i < argc; i++) { - if (!help_str && !argdesc) + if (!command->help && !command->argdesc) break; if (!strcmp(argv[i], "-h")) { - if (help_str) - printk("%s\n", help_str); - if (argdesc) - printk("Usage: %s\n", argdesc); + if (command->help) + printk("%s\n", command->help); + if (command->argdesc) + printk("Usage: %s\n", command->argdesc); return 0; } } - return handler(argc, argv); + return command->handler(argc, argv); } #if defined(CONFIG_CONSOLE_CHANNEL) && DT_NODE_EXISTS(DT_PATH(ec_console)) |