[PATCH linux dev-4.10 v2 2/2] drivers/i2c: Fix devicetree parsing in FSI-attached I2C master algo
Eddie James
eajames at linux.vnet.ibm.com
Fri Jun 30 02:42:36 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.
Signed-off-by: Edward A. James <eajames at us.ibm.com>
---
drivers/i2c/busses/i2c-fsi.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index b4eb102..d5135b4 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;
@@ -600,7 +601,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 +644,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