Commit 0a9c1475 authored by Jean Delvare's avatar Jean Delvare

i2c-algo-bit: Add pre- and post-xfer hooks

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: default avatarJean Delvare <khali@linux-fr.org>
Cc: Alex Deucher <alexdeucher@gmail.com>
parent d07b56b3
...@@ -522,6 +522,12 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -522,6 +522,12 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
int i, ret; int i, ret;
unsigned short nak_ok; 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"); bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
i2c_start(adap); i2c_start(adap);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
...@@ -570,6 +576,9 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -570,6 +576,9 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
bailout: bailout:
bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n"); bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
i2c_stop(adap); i2c_stop(adap);
if (adap->post_xfer)
adap->post_xfer(i2c_adap);
return ret; return ret;
} }
......
...@@ -36,6 +36,8 @@ struct i2c_algo_bit_data { ...@@ -36,6 +36,8 @@ struct i2c_algo_bit_data {
void (*setscl) (void *data, int state); void (*setscl) (void *data, int state);
int (*getsda) (void *data); int (*getsda) (void *data);
int (*getscl) (void *data); int (*getscl) (void *data);
int (*pre_xfer) (struct i2c_adapter *);
void (*post_xfer) (struct i2c_adapter *);
/* local settings */ /* local settings */
int udelay; /* half clock cycle time in us, int udelay; /* half clock cycle time in us,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment