]> git.baikalelectronics.ru Git - kernel.git/commitdiff
i2c-algo-bit: Add pre- and post-xfer hooks
authorJean Delvare <khali@linux-fr.org>
Sat, 13 Mar 2010 19:56:56 +0000 (20:56 +0100)
committerJean Delvare <khali@linux-fr.org>
Sat, 13 Mar 2010 19:56:56 +0000 (20:56 +0100)
Drivers might have to do random things before and/or after I2C
transfers. Add hooks to the i2c-algo-bit implementation to let them do
so.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Alex Deucher <alexdeucher@gmail.com>
drivers/i2c/algos/i2c-algo-bit.c
include/linux/i2c-algo-bit.h

index e25e13980af3543a7dea3b9a60ec61a64877631b..e8d568c3fb09ac2c6aefadd8e84c3aadf775a955 100644 (file)
@@ -522,6 +522,12 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
        int i, ret;
        unsigned short nak_ok;
 
+       if (adap->pre_xfer) {
+               ret = adap->pre_xfer(i2c_adap);
+               if (ret < 0)
+                       return ret;
+       }
+
        bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
        i2c_start(adap);
        for (i = 0; i < num; i++) {
@@ -570,6 +576,9 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
 bailout:
        bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
        i2c_stop(adap);
+
+       if (adap->post_xfer)
+               adap->post_xfer(i2c_adap);
        return ret;
 }
 
index 111334f5b92238664037059bed8f1fe431875337..4f98148c11c31971ef210d30ba8a83617c98ac11 100644 (file)
@@ -36,6 +36,8 @@ struct i2c_algo_bit_data {
        void (*setscl) (void *data, int state);
        int  (*getsda) (void *data);
        int  (*getscl) (void *data);
+       int  (*pre_xfer)  (struct i2c_adapter *);
+       void (*post_xfer) (struct i2c_adapter *);
 
        /* local settings */
        int udelay;             /* half clock cycle time in us,