Skip to contentSkip to conversation

i2c-core: allow either old or of_matching of devices

PATCH New Ben Dooks 1 participant 1 message Sep 23, 2015

Subsystems (2)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 i2c-core: allow either old or of_matching of devices

If an i2c-driver does not have an Linux specific id_table, but does have an of_match_table available then allow that to be probed by the i2c core code.

---
 drivers/i2c/i2c-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core.c +4 -1
index 5f89f1e..073c130 100644
@@ -455,6 +455,9 @@ static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
 static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
 						const struct i2c_client *client)
 {
+	if (!id)
+		return NULL;
+
 	while (id->name[0]) {
 		if (strcmp(client->name, id->name) == 0)
 			return id;
@@ -662,7 +665,7 @@ static int i2c_device_probe(struct device *dev)
 	}
 
 	driver = to_i2c_driver(dev->driver);
-	if (!driver->probe || !driver->id_table)
+	if (!driver->probe || !(driver->id_table || dev->driver->of_match_table))
 		return -ENODEV;
 
 	if (client->flags & I2C_CLIENT_WAKE) {
Signature · 1 line
2.5.1