[PATCH linux dev-4.10 2/4] i2c: fsi: Dynamically allocate port numbers

Joel Stanley joel at jms.id.au
Fri Jul 7 00:35:01 AEST 2017


The static allocation can collide if there are already devices
registered at the adapter number. Dynamic allocation is safer.

Users who wish to ensure a port appears at a specific number can use the
device tree alias feature.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 drivers/i2c/busses/i2c-fsi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index da045777624e..349bea0e2a63 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -584,14 +584,11 @@ static int fsi_i2c_probe(struct device *dev)
 		port->adapter.algo = &fsi_i2c_algorithm;
 		port->adapter.bus_recovery_info = &fsi_i2c_bus_recovery_info;
 		port->adapter.algo_data = port;
-		/* number ports uniquely */
-		port->adapter.nr = (i2c->idx * I2C_MASTER_NR_OFFSET) +
-			port_no;
 
 		snprintf(port->adapter.name, sizeof(port->adapter.name),
 				"fsi_i2c%u", port_no);
 
-		rc = i2c_add_numbered_adapter(&port->adapter);
+		rc = i2c_add_adapter(&port->adapter);
 		if (rc < 0)
 			return rc;
 
-- 
2.13.2



More information about the openbmc mailing list