Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / i2c / algos / i2c-algo-pca.c
index c3d912c..82946ac 100644 (file)
@@ -34,7 +34,7 @@
 #define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0)
 #define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0)
 
-static int i2c_debug=0;
+static int i2c_debug;
 
 #define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val)
 #define pca_inw(adap, reg) adap->read_byte(adap, reg)
@@ -49,7 +49,7 @@ static int i2c_debug=0;
 /*
  * Generate a start condition on the i2c bus.
  *
- * returns after the start condition has occured
+ * returns after the start condition has occurred
  */
 static void pca_start(struct i2c_algo_pca_data *adap)
 {
@@ -62,9 +62,9 @@ static void pca_start(struct i2c_algo_pca_data *adap)
 }
 
 /*
- * Generate a repeated start condition on the i2c bus 
+ * Generate a repeated start condition on the i2c bus
  *
- * return after the repeated start condition has occured
+ * return after the repeated start condition has occurred
  */
 static void pca_repeated_start(struct i2c_algo_pca_data *adap)
 {
@@ -82,7 +82,7 @@ static void pca_repeated_start(struct i2c_algo_pca_data *adap)
  * returns after the stop condition has been generated
  *
  * STOPs do not generate an interrupt or set the SI flag, since the
- * part returns the the idle state (0xf8). Hence we don't need to
+ * part returns the idle state (0xf8). Hence we don't need to
  * pca_wait here.
  */
 static void pca_stop(struct i2c_algo_pca_data *adap)
@@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
        int numbytes = 0;
        int state;
        int ret;
+       int timeout = 100;
 
-       state = pca_status(adap);
-       if ( state != 0xF8 ) {
-               dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state );
-               /* FIXME: what to do. Force stop ? */
-               return -EREMOTEIO;
+       while ((state = pca_status(adap)) != 0xf8 && timeout--) {
+               msleep(10);
+       }
+       if (state != 0xf8) {
+               dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state);
+               return -EIO;
        }
 
        DEB1("{{{ XFER %d messages\n", num);
@@ -354,8 +356,6 @@ static int pca_init(struct i2c_algo_pca_data *adap)
 }
 
 static struct i2c_algorithm pca_algo = {
-       .name           = "PCA9564 algorithm",
-       .id             = I2C_ALGO_PCA,
        .master_xfer    = pca_xfer,
        .functionality  = pca_func,
 };
@@ -369,8 +369,6 @@ int i2c_pca_add_bus(struct i2c_adapter *adap)
        int rval;
 
        /* register new adapter to i2c module... */
-
-       adap->id |= pca_algo.id;
        adap->algo = &pca_algo;
 
        adap->timeout = 100;            /* default values, should       */