[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <5aa3bd64a6082ded430ce27f5ea3f6956d1436ac.1575977795.git.vitor.soares@synopsys.com>
Date: Tue, 10 Dec 2019 16:37:32 +0100
From: Vitor Soares <Vitor.Soares@...opsys.com>
To: linux-kernel@...r.kernel.org, linux-i3c@...ts.infradead.org
Cc: Joao.Pinto@...opsys.com, bbrezillon@...nel.org,
gregkh@...uxfoundation.org, wsa@...-dreams.de, arnd@...db.de,
broonie@...nel.org, Vitor Soares <Vitor.Soares@...opsys.com>
Subject: [RFC 4/5] i3c: master: add i3c_for_each_dev helper
Introduce i3c_for_each_dev(), an i3c device iterator for use by i3cdev.
Signed-off-by: Vitor Soares <vitor.soares@...opsys.com>
---
drivers/i3c/internals.h | 1 +
drivers/i3c/master.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h
index bc062e8..a6deedf 100644
--- a/drivers/i3c/internals.h
+++ b/drivers/i3c/internals.h
@@ -24,4 +24,5 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev);
int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev,
const struct i3c_ibi_setup *req);
void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev);
+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 a9df276..cc41efe 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2640,6 +2640,18 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev)
dev->ibi = NULL;
}
+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)
{
return bus_register(&i3c_bus_type);
--
2.7.4
Powered by blists - more mailing lists