@@ -831,6 +831,19 @@ int uclass_id_count(enum uclass_id id)
return count;
}
+int uclass_id_on_reset(enum uclass_id id)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+
+ uclass_id_foreach_dev(id, dev, uc) {
+ if (dev->driver->on_reset)
+ return dev->driver->on_reset(dev);
+ }
+
+ return 0;
+}
+
UCLASS_DRIVER(nop) = {
.id = UCLASS_NOP,
.name = "nop",
@@ -454,6 +454,14 @@ int uclass_probe_all(enum uclass_id id);
*/
int uclass_id_count(enum uclass_id id);
+/**
+ * uclass_id_on_reset() - call on_reset for devices of a given uclass ID
+ *
+ * @id: uclass ID to look up
+ * Return: 0 if OK, other -ve on error
+ */
+int uclass_id_on_reset(enum uclass_id id);
+
/**
* uclass_id_foreach_dev() - iterate through devices of a given uclass ID
*
Implement a helper to call .on_reset method for every device in a certain uclass. Intention is to use this helper for UCLASS_SPI_FLASH before board reset to exit 4-byte adressing mode. Signed-off-by: Robert Marko <robert.marko@sartura.hr> --- drivers/core/uclass.c | 13 +++++++++++++ include/dm/uclass.h | 8 ++++++++ 2 files changed, 21 insertions(+)