[PATCH] i2c: Handle i2c_add_adapter failure in i2c algorithm drivers
authorMark M. Hoffman <mhoffman@lightlink.com>
Sat, 1 Jul 2006 15:16:06 +0000 (17:16 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 12 Jul 2006 22:43:07 +0000 (15:43 -0700)
Content-Disposition: inline; filename=i2c-algo-error-handling-fix.patch

It is possible for i2c_add_adapter() to fail.  Several I2C algorithm
drivers ignore that fact.  This (compile-tested only) patch fixes them.

Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/i2c/algos/i2c-algo-bit.c
drivers/i2c/algos/i2c-algo-ite.c
drivers/i2c/algos/i2c-algo-pca.c
drivers/i2c/algos/i2c-algo-pcf.c
drivers/i2c/algos/i2c-algo-sibyte.c

index df05df1a0ef61f20de8239e36bb3202ac7ae6ae5..3d6fc82c2cfcf040c640f64c74c7c0b48abc0cb2 100644 (file)
@@ -544,8 +544,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
        adap->timeout = 100;    /* default values, should       */
        adap->retries = 3;      /* be replaced by defines       */
 
-       i2c_add_adapter(adap);
-       return 0;
+       return i2c_add_adapter(adap);
 }
 
 
index 2db7bfc852252dbf1b74c29ede26071b522a92e1..70d8eefb5efcc44639b86bda6525fb084b76f04f 100644 (file)
@@ -742,10 +742,8 @@ int i2c_iic_add_bus(struct i2c_adapter *adap)
        adap->retries = 3;              /* be replaced by defines       */
        adap->flags = 0;
 
-       i2c_add_adapter(adap);
        iic_init(iic_adap);
-
-       return 0;
+       return i2c_add_adapter(adap);
 }
 
 
index 82946acab4c759ddeac4e2b235dd56eacf39fa3a..b88a6fcf7bd094abf75c67ba940cefe0fbd9ce58 100644 (file)
@@ -374,10 +374,10 @@ int i2c_pca_add_bus(struct i2c_adapter *adap)
        adap->timeout = 100;            /* default values, should       */
        adap->retries = 3;              /* be replaced by defines       */
 
-       rval = pca_init(pca_adap);
+       if ((rval = pca_init(pca_adap)))
+               return rval;
 
-       if (!rval)
-               i2c_add_adapter(adap);
+       rval = i2c_add_adapter(adap);
 
        return rval;
 }
index 6e498df1f717aea6f238b6ce91d990b9a7cbedfa..5b24930adb5a7b9e23721f47aca79daa7b450d04 100644 (file)
@@ -479,9 +479,11 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
        adap->timeout = 100;            /* default values, should       */
        adap->retries = 3;              /* be replaced by defines       */
 
-       rval = pcf_init_8584(pcf_adap);
-       if (!rval)
-               i2c_add_adapter(adap);
+       if ((rval = pcf_init_8584(pcf_adap)))
+               return rval;
+
+       rval = i2c_add_adapter(adap);
+
        return rval;
 }
 
index 3df3f09995c254806ed8c265eb3dfcb4c8cd08df..32d41c6fac0fccf0583bd53cb60b40b72c47632b 100644 (file)
@@ -173,9 +173,7 @@ int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
                printk("\n");
        }
 
-       i2c_add_adapter(i2c_adap);
-
-       return 0;
+       return i2c_add_adapter(i2c_adap);
 }