X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fi2c%2Falgos%2Fi2c-algo-pca.c;h=82946acab4c759ddeac4e2b235dd56eacf39fa3a;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=c3d912cbbbc339435cc1a57aa2c29b5e6bbbb210;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index c3d912cbb..82946acab 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -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 */