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>
This commit is contained in:
Simon Glass
2023-08-31 13:16:54 -04:00
committed by Tom Rini
parent b81a024e4a
commit ba5e3e1ed0
5 changed files with 79 additions and 8 deletions
+22
View File
@@ -18,6 +18,8 @@ struct test_state {
int val;
};
static bool called;
static int h_adder(void *ctx, struct event *event)
{
struct event_data_test *data = &event->data.test;
@@ -28,6 +30,14 @@ static int h_adder(void *ctx, struct event *event)
return 0;
}
static int h_adder_simple(void)
{
called = true;
return 0;
}
EVENT_SPY_SIMPLE(EVT_TEST, h_adder_simple);
static int test_event_base(struct unit_test_state *uts)
{
struct test_state state;
@@ -46,6 +56,18 @@ static int test_event_base(struct unit_test_state *uts)
}
COMMON_TEST(test_event_base, 0);
static int test_event_simple(struct unit_test_state *uts)
{
called = false;
/* Check that the handler is called */
ut_assertok(event_notify_null(EVT_TEST));
ut_assert(called);
return 0;
}
COMMON_TEST(test_event_simple, 0);
static int h_probe(void *ctx, struct event *event)
{
struct test_state *test_state = ctx;