i2c fsi fixes
Subsystems (2)
v2 cover i2c fsi fixes
From: "Edward A. James" <[email protected]>
Joel's fixes that I'm basing my dt changes and I2C dt parsing changes on.
Edward A. James (3):
i2c: fsi: Remove ida counter
i2c: fsi: Dynamically allocate port numbers
i2c: fsi: Remove idx counter
drivers/i2c/busses/i2c-fsi.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/3 i2c: fsi: Remove ida counter
From: "Edward A. James" <[email protected]>
It's not clear what the intention is. Regardless, it is not necessary so remove it.
--- drivers/i2c/busses/i2c-fsi.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/i2c/busses/i2c-fsi.c +3 -13
@@ -135,7 +135,6 @@ struct fsi_i2c_master {int idx;u8 fifo_size;struct list_head ports; -struct ida ida;wait_queue_head_t wait;struct semaphore lock; };
@@ -554,7 +553,7 @@ static int fsi_i2c_probe(struct device *dev)struct fsi_i2c_master *i2c;struct fsi_i2c_port *port;struct device_node *np; -int rc, idx; +int rc;u32 port_no; i2c =devm_kzalloc (dev,sizeof (*i2c),GFP_KERNEL );
@@ -565,7 +564,6 @@ static int fsi_i2c_probe(struct device *dev)sema_init (&i2c->lock,1 ); i2c->fsi =to_fsi_dev (dev); i2c->idx =ida_simple_get (&fsi_i2c_ida,1 ,INT_MAX ,GFP_KERNEL ); -ida_init (&i2c->ida);INIT_LIST_HEAD (&i2c->ports);if (dev->of_node) {
@@ -575,12 +573,6 @@ static int fsi_i2c_probe(struct device *dev)if (rc || port_no >0xFFFF )continue ; -/* make sure we don't overlap index with a buggy dts */ - idx =ida_simple_get (&i2c->ida, port_no, - port_no +1 ,GFP_KERNEL ); -if (idx <0 ) -continue ; - port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL );if (!port)return -ENOMEM ;
@@ -599,8 +591,8 @@ static int fsi_i2c_probe(struct device *dev) port_no;snprintf (port->adapter.name, -sizeof (port->adapter.name), -"fsi_i2c-%u" , port_no); +sizeof (port->adapter.name),"fsi_i2c-%u" , + port_no); rc =i2c_add_numbered_adapter (&port->adapter);if (rc <0 )
@@ -628,8 +620,6 @@ static int fsi_i2c_remove(struct device *dev)i2c_del_adapter (&port->adapter); } -ida_destroy (&i2c->ida); -ida_simple_remove (&fsi_i2c_ida, i2c->idx);return 0 ;
Signature · 1 line
1.8.3.1
PATCH v2 2/3 i2c: fsi: Dynamically allocate port numbers
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
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.
--- drivers/i2c/busses/i2c-fsi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/busses/i2c-fsi.c +1 -4
@@ -586,15 +586,12 @@ static int fsi_i2c_probe(struct device *dev) 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;
Signature · 1 line
1.8.3.1
PATCH v2 3/3 i2c: fsi: Remove idx counter
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
It is no longer used.
--- drivers/i2c/busses/i2c-fsi.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/i2c/busses/i2c-fsi.c +0 -6
@@ -132,7 +132,6 @@struct fsi_i2c_master {struct fsi_device *fsi; -int idx;u8 fifo_size;struct list_head ports;wait_queue_head_t wait;
@@ -147,8 +146,6 @@ struct fsi_i2c_port {u16 xfrd; }; -static DEFINE_IDA (fsi_i2c_ida); -static int fsi_i2c_read_reg (struct fsi_device *fsi,unsigned int reg,u32 *data) {
@@ -563,7 +560,6 @@ static int fsi_i2c_probe(struct device *dev)init_waitqueue_head (&i2c->wait);sema_init (&i2c->lock,1 ); i2c->fsi =to_fsi_dev (dev); - i2c->idx =ida_simple_get (&fsi_i2c_ida,1 ,INT_MAX ,GFP_KERNEL );INIT_LIST_HEAD (&i2c->ports);if (dev->of_node) {
@@ -617,8 +613,6 @@ static int fsi_i2c_remove(struct device *dev)i2c_del_adapter (&port->adapter); } -ida_simple_remove (&fsi_i2c_ida, i2c->idx); -return 0 ; }
Signature · 1 line
1.8.3.1