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>
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 02002ac..c420726 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 @@
}
#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 effd58c..f4c12d7 100644
--- a/include/event.h
+++ b/include/event.h
@@ -19,6 +19,12 @@
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 @@
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;
};
/**