Skip to contentSkip to conversation

Add static bus numbering support to i2c-versatile

PATCH In review Catalin Marinas 2 participants 5 messages Feb 9, 2009 – Feb 10, 2009 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add static bus numbering support to i2c-versatile

If dev->id is not -1, the platform code may use static bus numbering rather than dynamic. The patch also changes the i2c_versatile_init to a subsys_initcall rather than module_init to make sure it is initialised before the I2C devices initialisation.

Cc Russell King <rmk-lFZ/[email protected]>
---
 drivers/i2c/busses/i2c-versatile.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-versatile.c +9 -2
index 4678bab..15b5e8a 100644
@@ -96,13 +96,20 @@ static int i2c_versatile_probe(struct platform_device *dev)
 	writel(SCL | SDA, i2c->base + I2C_CONTROLS);
 
 	i2c->adap.owner = THIS_MODULE;
+	if (dev->id >= 0)
+		i2c->adap.nr = dev->id;
 	strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name));
 	i2c->adap.algo_data = &i2c->algo;
 	i2c->adap.dev.parent = &dev->dev;
 	i2c->algo = i2c_versatile_algo;
 	i2c->algo.data = i2c;
 
-	ret = i2c_bit_add_bus(&i2c->adap);
+	if (dev->id >= 0)
+		/* static bus numbering */
+		ret = i2c_bit_add_numbered_bus(&i2c->adap);
+	else
+		/* dynamic bus numbering */
+		ret = i2c_bit_add_bus(&i2c->adap);
 	if (ret >= 0) {
 		platform_set_drvdata(dev, i2c);
 		return 0;
@@ -146,7 +153,7 @@ static void __exit i2c_versatile_exit(void)
 	platform_driver_unregister(&i2c_versatile_driver);
 }
 
-module_init(i2c_versatile_init);
+subsys_initcall(i2c_versatile_init);
 module_exit(i2c_versatile_exit);
 
 MODULE_DESCRIPTION("ARM Versatile I2C bus driver");

A message that is not in the archive (sent off-list or not yet received): 20090209180338.27227.77460.stgit-hhZApKj8DF/[email protected]

#2 lore raw
Quoted 24 lines · Catalin Marinas

If dev->id is not -1, the platform code may use static bus numbering rather than dynamic. The patch also changes the i2c_versatile_init to a subsys_initcall rather than module_init to make sure it is initialised before the I2C devices initialisation.

Cc Russell King <rmk-lFZ/[email protected]>
---
 drivers/i2c/busses/i2c-versatile.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-versatile.c +2 -0
index 4678bab..15b5e8a 100644
@@ -96,13 +96,20 @@ static int i2c_versatile_probe(struct platform_device *dev)
 	writel(SCL | SDA, i2c->base + I2C_CONTROLS);
 
 	i2c->adap.owner = THIS_MODULE;
+	if (dev->id >= 0)
+		i2c->adap.nr = dev->id;
 	strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name));
 	i2c->adap.algo_data = &i2c->algo;
 	i2c->adap.dev.parent = &dev->dev;

drivers/i2c/busses/i2c-versatile.c static int i2c_versatile_probe(struct platform_device *dev) · line 112

Quoted 10 lines
drivers/i2c/busses/i2c-versatile.c +6 -1
 	i2c->algo = i2c_versatile_algo;
 	i2c->algo.data = i2c;
 
-	ret = i2c_bit_add_bus(&i2c->adap);
+	if (dev->id >= 0)
+		/* static bus numbering */
+		ret = i2c_bit_add_numbered_bus(&i2c->adap);
+	else
+		/* dynamic bus numbering */
+		ret = i2c_bit_add_bus(&i2c->adap);

Why don't you merge both tests? This would simplify the code and make it clearer.

Quoted 12 lines
drivers/i2c/busses/i2c-versatile.c +1 -1
 	if (ret >= 0) {
 		platform_set_drvdata(dev, i2c);
 		return 0;
@@ -146,7 +153,7 @@ static void __exit i2c_versatile_exit(void)
 	platform_driver_unregister(&i2c_versatile_driver);
 }
 
-module_init(i2c_versatile_init);
+subsys_initcall(i2c_versatile_init);
 module_exit(i2c_versatile_exit);
 
 MODULE_DESCRIPTION("ARM Versatile I2C bus driver");
Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 17 lines · Jean Delvare
Quoted 16 lines · Catalin Marinas
drivers/i2c/busses/i2c-versatile.c +2 -0
index 4678bab..15b5e8a 100644
@@ -96,13 +96,20 @@ static int i2c_versatile_probe(struct platform_device *dev)
      writel(SCL | SDA, i2c->base + I2C_CONTROLS);
 
      i2c->adap.owner = THIS_MODULE;
+     if (dev->id >= 0)
+             i2c->adap.nr = dev->id;
      strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name));
      i2c->adap.algo_data = &i2c->algo;
      i2c->adap.dev.parent = &dev->dev;
      i2c->algo = i2c_versatile_algo;
      i2c->algo.data = i2c;
 
Quoted 10 lines

drivers/i2c/busses/i2c-versatile.c static int i2c_versatile_probe(struct platform_device *dev) · line 112

Quoted 7 lines
drivers/i2c/busses/i2c-versatile.c +6 -1
-     ret = i2c_bit_add_bus(&i2c->adap);
+     if (dev->id >= 0)
+             /* static bus numbering */
+             ret = i2c_bit_add_numbered_bus(&i2c->adap);
+     else
+             /* dynamic bus numbering */
+             ret = i2c_bit_add_bus(&i2c->adap);

Why don't you merge both tests? This would simplify the code and make it clearer.

Good point. Please see below. Thanks.

Add static bus numbering support to i2c-versatile

From: Catalin Marinas <[email protected]>

If dev->id is not -1, the platform code may use static bus numbering rather than dynamic. The patch also changes the i2c_versatile_init to a subsys_initcall rather than module_init to make sure it is initialised before the I2C devices initialisation.

Cc Russell King <rmk-lFZ/[email protected]>
---
 drivers/i2c/busses/i2c-versatile.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-versatile.c +8 -2
index 4678bab..fede619 100644
@@ -102,7 +102,13 @@ static int i2c_versatile_probe(struct platform_device *dev)
 	i2c->algo = i2c_versatile_algo;
 	i2c->algo.data = i2c;
 
-	ret = i2c_bit_add_bus(&i2c->adap);
+	if (dev->id >= 0) {
+		/* static bus numbering */
+		i2c->adap.nr = dev->id;
+		ret = i2c_bit_add_numbered_bus(&i2c->adap);
+	} else
+		/* dynamic bus numbering */
+		ret = i2c_bit_add_bus(&i2c->adap);
 	if (ret >= 0) {
 		platform_set_drvdata(dev, i2c);
 		return 0;
@@ -146,7 +152,7 @@ static void __exit i2c_versatile_exit(void)
 	platform_driver_unregister(&i2c_versatile_driver);
 }
 
-module_init(i2c_versatile_init);
+subsys_initcall(i2c_versatile_init);
 module_exit(i2c_versatile_exit);
 
 MODULE_DESCRIPTION("ARM Versatile I2C bus driver");
Signature · 1 line
Catalin

A message that is not in the archive (sent off-list or not yet received): 1234268669.8798.10.camel-hhZApKj8DF/[email protected]

Acked-by
#6 lore raw
Quoted 35 lines

Add static bus numbering support to i2c-versatile

From: Catalin Marinas <[email protected]>

If dev->id is not -1, the platform code may use static bus numbering rather than dynamic. The patch also changes the i2c_versatile_init to a subsys_initcall rather than module_init to make sure it is initialised before the I2C devices initialisation.

Cc Russell King <rmk-lFZ/[email protected]>
---
 drivers/i2c/busses/i2c-versatile.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-versatile.c +7 -1
index 4678bab..fede619 100644
@@ -102,7 +102,13 @@ static int i2c_versatile_probe(struct platform_device *dev)
 	i2c->algo = i2c_versatile_algo;
 	i2c->algo.data = i2c;
 
-	ret = i2c_bit_add_bus(&i2c->adap);
+	if (dev->id >= 0) {
+		/* static bus numbering */
+		i2c->adap.nr = dev->id;
+		ret = i2c_bit_add_numbered_bus(&i2c->adap);
+	} else
+		/* dynamic bus numbering */
+		ret = i2c_bit_add_bus(&i2c->adap);
 	if (ret >= 0) {
 		platform_set_drvdata(dev, i2c);
 		return 0;

drivers/i2c/busses/i2c-versatile.c static void __exit i2c_versatile_exit(void) · line 158

Quoted 8 lines
drivers/i2c/busses/i2c-versatile.c +1 -1
@@ -146,7 +152,7 @@ static void __exit i2c_versatile_exit(void)
 	platform_driver_unregister(&i2c_versatile_driver);
 }
 
-module_init(i2c_versatile_init);
+subsys_initcall(i2c_versatile_init);
 module_exit(i2c_versatile_exit);
 
 MODULE_DESCRIPTION("ARM Versatile I2C bus driver");

Note that i2c-versatile is not under my jurisdiction so you will have to push this patch through either Ben Dooks or the arm tree.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 1 line · Jean Delvare
Quoted 1 line

Add static bus numbering support to i2c-versatile

[...]

Quoted 4 lines

Note that i2c-versatile is not under my jurisdiction so you will have to push this patch through either Ben Dooks or the arm tree.

Russell, since you wrote the code originally, are you OK with me sending it to your patch system?

Thanks.

Signature · 1 line
Catalin