diff options
author | Simon Glass <sjg@chromium.org> | 2022-03-04 18:43:03 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-03-10 16:28:36 +0300 |
commit | 5b896ed5856f768cdd55cdeb44c5f8f6b6a7a18a (patch) | |
tree | 427918a7828619a8620cd9b95d547539c9eb6733 /include | |
parent | 5a4219043d659514316e41d3d09866030c773e78 (diff) | |
download | u-boot-5b896ed5856f768cdd55cdeb44c5f8f6b6a7a18a.tar.xz |
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 <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/dm/device-internal.h | 10 | ||||
-rw-r--r-- | include/event.h | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 02002acb78..c420726287 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 <event.h> #include <linker_lists.h> #include <dm/ofnode.h> @@ -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 effd58c704..f4c12d768b 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; }; /** |