diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2021-07-07 14:47:57 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-10 21:53:26 +0000 |
commit | e3ded643c83a1fd87d800b37dc4b7a7f7f3f137f (patch) | |
tree | 2074753a8276194bf0a999bdaeb011d37e1af61c /zephyr/shim/src | |
parent | d89284053e21cd21ebd5f5853d0de81709c72f08 (diff) | |
download | chrome-ec-e3ded643c83a1fd87d800b37dc4b7a7f7f3f137f.tar.gz |
zephyr: shim: reimplement host commands using iterables
Rewrite the host command shim using Zephyr iterable sections. This
allows initializing the HC structure statically and gets rid of the
runtime init code entirely.
BRANCH=none
BUG=b:195521227
TEST=build and run on volteer
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: I94a55f8eb3e1d58de6a1d93c31b6170a5541a1fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010284
Commit-Queue: Keith Short <keithshort@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r-- | zephyr/shim/src/host_command.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/zephyr/shim/src/host_command.c b/zephyr/shim/src/host_command.c index 6d586f225a..bf863b48de 100644 --- a/zephyr/shim/src/host_command.c +++ b/zephyr/shim/src/host_command.c @@ -5,32 +5,11 @@ #include "host_command.h" -static struct zshim_host_command_node *host_command_head; - -void zshim_setup_host_command( - int command, - enum ec_status (*routine)(struct host_cmd_handler_args *args), - int version_mask, struct zshim_host_command_node *entry) -{ - struct zshim_host_command_node **loc = &host_command_head; - - /* Setup the entry */ - entry->cmd->handler = routine; - entry->cmd->command = command; - entry->cmd->version_mask = version_mask; - entry->next = *loc; - - /* Insert the entry */ - *loc = entry; -} - struct host_command *zephyr_find_host_command(int command) { - struct zshim_host_command_node *p; - - for (p = host_command_head; p != NULL; p = p->next) { - if (p->cmd->command == command) - return p->cmd; + STRUCT_SECTION_FOREACH(host_command, cmd) { + if (cmd->command == command) + return cmd; } return NULL; |