From 5b896ed5856f768cdd55cdeb44c5f8f6b6a7a18a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 4 Mar 2022 08:43:03 -0700 Subject: event: Add events for device probe/remove Generate events when devices are probed or removed, allowing hooks to be added for these situations. This is controlled by the DM_EVENT config option. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 10 ++++++++++ include/event.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 02002acb787..c420726287e 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -10,6 +10,7 @@ #ifndef _DM_DEVICE_INTERNAL_H #define _DM_DEVICE_INTERNAL_H +#include #include #include @@ -426,4 +427,13 @@ static inline void devres_release_all(struct udevice *dev) } #endif /* ! CONFIG_DEVRES */ + +static inline int device_notify(const struct udevice *dev, enum event_t type) +{ +#if CONFIG_IS_ENABLED(DM_EVENT) + return event_notify(type, &dev, sizeof(dev)); +#else + return 0; +#endif +} #endif diff --git a/include/event.h b/include/event.h index effd58c7047..f4c12d768b4 100644 --- a/include/event.h +++ b/include/event.h @@ -19,6 +19,12 @@ enum event_t { EVT_NONE, EVT_TEST, + /* Events related to driver model */ + EVT_DM_PRE_PROBE, + EVT_DM_POST_PROBE, + EVT_DM_PRE_REMOVE, + EVT_DM_POST_REMOVE, + EVT_COUNT }; @@ -31,6 +37,15 @@ union event_data { struct event_data_test { int signal; } test; + + /** + * struct event_dm - driver model event + * + * @dev: Device this event relates to + */ + struct event_dm { + struct udevice *dev; + } dm; }; /** -- cgit v1.3.1