diff options
author | Simon Glass | 2023-08-21 21:16:48 -0600 |
---|---|---|
committer | Tom Rini | 2023-08-31 13:16:54 -0400 |
commit | ba5e3e1ed0afb3daa446d2168e5c8c9fe119cbaf (patch) | |
tree | d265d9442db79b365039fc727d5d0cbe987fbd58 /include/event.h | |
parent | b81a024e4a37097d3dcffccb225850f8f6dc8277 (diff) |
event: Support a simple spy record
The current event spy is always passed the event context and the event.
The context is always NULL for a static spy. The event is not often used.
Introduce a 'simple' spy which takes no arguments. This allows us to drop
the adaptation code that many of these spy records use.
Update the event script to find these in the image.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/event.h')
-rw-r--r-- | include/event.h | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/include/event.h b/include/event.h index daf44bf8a83..0e3222c2e24 100644 --- a/include/event.h +++ b/include/event.h @@ -99,19 +99,48 @@ struct event { union event_data data; }; +/* Flags for event spy */ +enum evspy_flags { + EVSPYF_SIMPLE = 1 << 0, +}; + /** Function type for event handlers */ typedef int (*event_handler_t)(void *ctx, struct event *event); +/** Function type for simple event handlers */ +typedef int (*event_handler_simple_t)(void); + /** * struct evspy_info - information about an event spy * * @func: Function to call when the event is activated (must be first) * @type: Event type + * @flag: Flags for this spy * @id: Event id string */ struct evspy_info { event_handler_t func; - enum event_t type; + u8 type; + u8 flags; +#if CONFIG_IS_ENABLED(EVENT_DEBUG) + const char *id; +#endif +}; + +/** + * struct evspy_info_simple - information about an event spy + * + * THis is the 'simple' record, the only difference being the handler function + * + * @func: Function to call when the event is activated (must be first) + * @type: Event type + * @flag: Flags for this spy + * @id: Event id string + */ +struct evspy_info_simple { + event_handler_simple_t func; + u8 type; + u8 flags; #if CONFIG_IS_ENABLED(EVENT_DEBUG) const char *id; #endif @@ -119,9 +148,11 @@ struct evspy_info { /* Declare a new event spy */ #if CONFIG_IS_ENABLED(EVENT_DEBUG) -#define _ESPY_REC(_type, _func) { _func, _type, #_func, } +#define _ESPY_REC(_type, _func) { _func, _type, 0, #_func, } +#define _ESPY_REC_SIMPLE(_type, _func) { _func, _type, EVSPYF_SIMPLE, #_func, } #else #define _ESPY_REC(_type, _func) { _func, _type, } +#define _ESPY_REC_SIMPLE(_type, _func) { _func, _type, EVSPYF_SIMPLE } #endif static inline const char *event_spy_id(struct evspy_info *spy) @@ -168,6 +199,12 @@ static inline const char *event_spy_id(struct evspy_info *spy) __used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \ evspy_info) = _ESPY_REC(_type, _func) +/* Simple spy with no function arguemnts */ +#define EVENT_SPY_SIMPLE(_type, _func) \ + __used ll_entry_declare(struct evspy_info_simple, \ + _type ## _3_ ## _func, \ + evspy_info) = _ESPY_REC_SIMPLE(_type, _func) + /** * event_register - register a new spy * |