i2c-ibm_iic: Add support for new-style clients
authorStefan Roese <sr@denx.de>
Sat, 13 Oct 2007 21:56:30 +0000 (23:56 +0200)
committerJean Delvare <khali@hyperion.delvare>
Sat, 13 Oct 2007 21:56:30 +0000 (23:56 +0200)
Use i2c_bit_add_numbered_adapter() if device id specified, so that the
i2c-ibm_iic adapter works well with new-style pre-declared devices.

Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/busses/i2c-ibm_iic.c

index 8b14d14e60cad3e3cd1099df6d221dc6ab1b475e..e08bacadd6bc2ae7adc0445341d8996eff6ddee5 100644 (file)
@@ -738,7 +738,14 @@ static int __devinit iic_probe(struct ocp_device *ocp){
        adap->timeout = 1;
        adap->retries = 1;
 
-       if ((ret = i2c_add_adapter(adap)) != 0){
+       /*
+        * If "dev->idx" is negative we consider it as zero.
+        * The reason to do so is to avoid sysfs names that only make
+        * sense when there are multiple adapters.
+        */
+       adap->nr = dev->idx >= 0 ? dev->idx : 0;
+
+       if ((ret = i2c_add_numbered_adapter(adap)) < 0) {
                printk(KERN_CRIT "ibm-iic%d: failed to register i2c adapter\n",
                        dev->idx);
                goto fail;