@@ -124,6 +124,14 @@ static int of_dev_or_parent_node_match(struct device *dev, const void *data)
return 0;
}
+static int of_i2c_adapter_match(struct device *dev, const void *data)
+{
+ if (!of_dev_or_parent_node_match(dev, data))
+ return 0;
+
+ return !!i2c_verify_adapter(dev);
+}
+
/* must call put_device() when done with returned i2c_client device */
struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
{
@@ -146,18 +154,13 @@ EXPORT_SYMBOL(of_find_i2c_device_by_node);
struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
{
struct device *dev;
- struct i2c_adapter *adapter;
dev = bus_find_device(&i2c_bus_type, NULL, node,
- of_dev_or_parent_node_match);
+ of_i2c_adapter_match);
if (!dev)
return NULL;
- adapter = i2c_verify_adapter(dev);
- if (!adapter)
- put_device(dev);
-
- return adapter;
+ return to_i2c_adapter(dev);
}
EXPORT_SYMBOL(of_find_i2c_adapter_by_node);