summaryrefslogtreecommitdiff
path: root/zephyr/shim/include
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-07-08 18:07:06 +0000
committerCommit Bot <commit-bot@chromium.org>2021-08-10 21:53:32 +0000
commit64cda0a13de4056c13c8a62b756008480be6b425 (patch)
tree481f342135e489db5603903326e342ef06a2c5c8 /zephyr/shim/include
parent2e9af0c566b905d2aa5c5d1bd7c692e549929ff1 (diff)
downloadchrome-ec-64cda0a13de4056c13c8a62b756008480be6b425.tar.gz
zephyr: shim: reimplement hooks using iterables
Reimplement the hooks shim code using Zephyr iterable sections. Keep the existing hook_registry based structure, gets rid of the per-hook init functions and instead initializes all the list nodes from a single init call. BRANCH=none BUG=b:195521227 TEST=build and run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ic166d214ee1dcd1431ec484e5014cb297f7fb8c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3069399 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')
-rw-r--r--zephyr/shim/include/zephyr_hooks_shim.h32
1 files changed, 8 insertions, 24 deletions
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h
index 6edfdfe0a9..7175b5a6af 100644
--- a/zephyr/shim/include/zephyr_hooks_shim.h
+++ b/zephyr/shim/include/zephyr_hooks_shim.h
@@ -53,33 +53,17 @@ int hook_call_deferred(const struct deferred_data *data, int us);
struct zephyr_shim_hook_list {
void (*routine)(void);
int priority;
+ enum hook_type type;
struct zephyr_shim_hook_list *next;
};
/**
- * Runtime helper for DECLARE_HOOK setup data.
- *
- * @param type The type of hook.
- * @param routine The handler for the hook.
- * @param priority The priority (smaller values are executed first).
- * @param entry A statically allocated list entry.
- */
-void zephyr_shim_setup_hook(enum hook_type type, void (*routine)(void),
- int priority, struct zephyr_shim_hook_list *entry);
-
-/**
* See include/hooks.h for documentation.
*/
-#define DECLARE_HOOK(hooktype, routine, priority) \
- _DECLARE_HOOK_1(hooktype, routine, priority, __LINE__)
-#define _DECLARE_HOOK_1(hooktype, routine, priority, line) \
- _DECLARE_HOOK_2(hooktype, routine, priority, line)
-#define _DECLARE_HOOK_2(hooktype, routine, priority, line) \
- static int _setup_hook_##line(const struct device *unused) \
- { \
- ARG_UNUSED(unused); \
- static struct zephyr_shim_hook_list lst; \
- zephyr_shim_setup_hook(hooktype, routine, priority, &lst); \
- return 0; \
- } \
- SYS_INIT(_setup_hook_##line, APPLICATION, 1)
+#define DECLARE_HOOK(_hooktype, _routine, _priority) \
+ STRUCT_SECTION_ITERABLE(zephyr_shim_hook_list, \
+ _cros_hook_##_hooktype##_##_routine) = { \
+ .type = _hooktype, \
+ .routine = _routine, \
+ .priority = _priority, \
+ }