[PATCH v4 2/3] i3c: master: add i3c_for_each_dev helper
From: Sam Agazaryan
Date: Sun Sep 06 2026 - 16:29:38 EST
From: Vitor Soares <vitor.soares@xxxxxxxxxxx>
Introduce i3c_for_each_dev(), an i3c device iterator for use by i3cdev.
Signed-off-by: Vitor Soares <vitor.soares@xxxxxxxxxxx>
Signed-off-by: Sam Agazaryan <samagazaryan@xxxxxxxxxx>
---
drivers/i3c/internals.h | 2 ++
drivers/i3c/master.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h
index cbc00c862104..3c53a5108b81 100644
--- a/drivers/i3c/internals.h
+++ b/drivers/i3c/internals.h
@@ -79,4 +79,6 @@ static inline struct i3c_master_controller *i3c_bus_to_i3c_master(struct i3c_bus
return container_of(i3cbus, struct i3c_master_controller, bus);
}
+int i3c_for_each_dev(void *data, int (*fn)(struct device *, void *));
+
#endif /* I3C_INTERNAL_H */
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index e8a9f8c3041e..dd5071ca9195 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -4011,6 +4011,18 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev)
}
EXPORT_SYMBOL_GPL(i3c_dev_free_ibi_locked);
+int i3c_for_each_dev(void *data, int (*fn)(struct device *, void *))
+{
+ int res;
+
+ mutex_lock(&i3c_core_lock);
+ res = bus_for_each_dev(&i3c_bus_type, NULL, data, fn);
+ mutex_unlock(&i3c_core_lock);
+
+ return res;
+}
+EXPORT_SYMBOL_GPL(i3c_for_each_dev);
+
static int __init i3c_init(void)
{
int res;
--
2.55.0.979.g7e5102b832-goog