summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/zephyr_hooks_shim.h
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/include/zephyr_hooks_shim.h')
-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, \
+ }