[ARM] 5394/1: Add static bus numbering support to i2c-versatile
authorCatalin Marinas <catalin.marinas@arm.com>
Thu, 12 Feb 2009 14:57:20 +0000 (15:57 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 19 Feb 2009 11:30:22 +0000 (11:30 +0000)
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.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/i2c/busses/i2c-versatile.c

index 4678babd3ce617dccc65975b2e178e615a2f3d87..fede619ba227b2c5ef9e45f5be24af056f93661a 100644 (file)
@@ -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");