[PATCH 07/29] i2c: implement of_find_i2c_adapter_by_node
Sascha Hauer
s.hauer at pengutronix.de
Fri Mar 14 10:32:27 EDT 2014
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/i2c/i2c.c | 11 +++++++++++
include/i2c/i2c.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index e289a35..9873957 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -405,6 +405,17 @@ struct i2c_adapter *i2c_get_adapter(int busnum)
return NULL;
}
+struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
+{
+ struct i2c_adapter *adap;
+
+ list_for_each_entry(adap, &adapter_list, list)
+ if (adap->dev.device_node == node)
+ return adap;
+
+ return NULL;
+}
+
/**
* i2c_add_numbered_adapter - declare i2c adapter, use static bus number
* @adapter: the adapter to register (with adap->nr initialized)
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 81e5daa..f89fefb 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -133,6 +133,7 @@ static inline int i2c_register_board_info(int busnum,
#endif
extern int i2c_add_numbered_adapter(struct i2c_adapter *adapter);
struct i2c_adapter *i2c_get_adapter(int busnum);
+struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node);
/* For devices that use several addresses, use i2c_new_dummy() to make
* client handles for the extra addresses.
--
1.9.0
More information about the barebox
mailing list