diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2021-07-08 17:36:16 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-10 21:53:27 +0000 |
commit | 2e9af0c566b905d2aa5c5d1bd7c692e549929ff1 (patch) | |
tree | a69bd06f06f5d450bb13bf11f61dd75551219855 /zephyr/shim/include/zephyr_mkbp_event.h | |
parent | e3ded643c83a1fd87d800b37dc4b7a7f7f3f137f (diff) | |
download | chrome-ec-2e9af0c566b905d2aa5c5d1bd7c692e549929ff1.tar.gz |
zephyr: shim: reimplement mkbp_event using iterables
Rewrite the MKBP events shim using iterable sections.
BRANCH=none
BUG=b:195521227
TEST=build and run on volteer
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: Ia96fb9ec06b1a86b1be293209db317a361ae4741
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3069398
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim/include/zephyr_mkbp_event.h')
-rw-r--r-- | zephyr/shim/include/zephyr_mkbp_event.h | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/zephyr/shim/include/zephyr_mkbp_event.h b/zephyr/shim/include/zephyr_mkbp_event.h index b37ce0d5d3..159aebc8e1 100644 --- a/zephyr/shim/include/zephyr_mkbp_event.h +++ b/zephyr/shim/include/zephyr_mkbp_event.h @@ -10,39 +10,14 @@ #endif #define __CROS_EC_ZEPHYR_MKBP_EVENT_H -/** Node in a list of mkbp event handlers */ -struct zshim_mkbp_event_node { - struct mkbp_event_source evtsrc; - struct zshim_mkbp_event_node *next; -}; - -/** - * Runtime helper for DECLARE_EVENT_SOURCE setup data. - * - * @param event_type event type (EC_MKBP_EVENT_...) - * @param get_data event handler for the event type - * @param entry pointer to statically allocated zshim_mkbp_event_node - item - */ -void zshim_setup_mkbp_event(uint8_t event_type, int (*get_data)(uint8_t *data), - struct zshim_mkbp_event_node *entry); - const struct mkbp_event_source *zephyr_find_mkbp_event_source( uint8_t event_type); /** * See include/mkbp_event.h for documentation. */ -#define DECLARE_EVENT_SOURCE(type, func) \ - _DECLARE_EVENT_SOURCE_1(type, func, __LINE__) -#define _DECLARE_EVENT_SOURCE_1(type, func, line) \ - _DECLARE_EVENT_SOURCE_2(type, func, line) -#define _DECLARE_EVENT_SOURCE_2(type, func, line) \ - static int _setup_mkbp_event_##line(const struct device *unused) \ - { \ - ARG_UNUSED(unused); \ - static struct zshim_mkbp_event_node mkbp_event; \ - zshim_setup_mkbp_event(type, func, &mkbp_event); \ - return 0; \ - } \ - SYS_INIT(_setup_mkbp_event_##line, APPLICATION, 1) +#define DECLARE_EVENT_SOURCE(_type, _func) \ + STRUCT_SECTION_ITERABLE(mkbp_event_source, _cros_evtsrc_##_func) = { \ + .event_type = _type, \ + .get_data = _func, \ + } |