[PATCH linux dev-4.10 v3 3/3] drivers/i2c: Fix devicetree parsing in FSI-attached I2C master algo

Eddie James eajames at linux.vnet.ibm.com
Fri Jul 7 07:44:29 AEST 2017


From: "Edward A. James" <eajames at us.ibm.com>

Add compatible check for the master device node. Change "port" to "reg"
for the port number property. Check that the port node is available. Add
the device node to the adapter device.

Signed-off-by: Edward A. James <eajames at us.ibm.com>
---
 drivers/i2c/busses/i2c-fsi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index b4eb102..79a6985 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -568,10 +568,11 @@ static int fsi_i2c_probe(struct device *dev)
 	ida_init(&i2c->ida);
 	INIT_LIST_HEAD(&i2c->ports);
 
-	if (dev->of_node) {
+	if (dev->of_node &&
+	    of_device_is_compatible(dev->of_node, "ibm,fsi-i2c-master")) {
 		/* add adapter for each i2c port of the master */
-		for_each_child_of_node(dev->of_node, np) {
-			rc = of_property_read_u32(np, "port", &port_no);
+		for_each_available_child_of_node(dev->of_node, np) {
+			rc = of_property_read_u32(np, "reg", &port_no);
 			if (rc || port_no > 0xFFFF)
 				continue;
 
@@ -589,6 +590,7 @@ static int fsi_i2c_probe(struct device *dev)
 			port->port = (u16)port_no;
 
 			port->adapter.owner = THIS_MODULE;
+			port->adapter.dev.of_node = np;
 			port->adapter.dev.parent = dev;
 			port->adapter.algo = &fsi_i2c_algorithm;
 			port->adapter.bus_recovery_info =
@@ -600,7 +602,7 @@ static int fsi_i2c_probe(struct device *dev)
 
 			snprintf(port->adapter.name,
 				 sizeof(port->adapter.name),
-				 "fsi_i2c-%u", port_no);
+				 "fsi%d_i2c%u", i2c->idx, port_no);
 
 			rc = i2c_add_numbered_adapter(&port->adapter);
 			if (rc < 0)
@@ -643,7 +645,7 @@ static int fsi_i2c_remove(struct device *dev)
 static struct fsi_driver fsi_i2c_driver = {
 	.id_table = fsi_i2c_ids,
 	.drv = {
-		.name = "i2c_master_fsi",
+		.name = "fsi_i2c_master",
 		.bus = &fsi_bus_type,
 		.probe = fsi_i2c_probe,
 		.remove = fsi_i2c_remove,
-- 
1.8.3.1



More information about the openbmc mailing list