@@ -549,12 +549,17 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
i2c_start(adap);
for (i = 0; i < num; i++) {
+ bool did_stop = false;
+
pmsg = &msgs[i];
nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
if (!(pmsg->flags & I2C_M_NOSTART)) {
- if (i) {
- bit_dbg(3, &i2c_adap->dev, "emitting "
- "repeated start condition\n");
+ if (did_stop) {
+ bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
+ i2c_start(adap);
+ did_stop = false;
+ } else if (i) {
+ bit_dbg(3, &i2c_adap->dev, "emitting repeated start condition\n");
i2c_repstart(adap);
}
ret = bit_doAddress(i2c_adap, pmsg);
@@ -588,6 +593,12 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
goto bailout;
}
}
+
+ if (pmsg->flags & I2C_M_STOP && i != num - 1) {
+ bit_dbg(3, &i2c_adap->dev, "emitting enforced stop condition\n");
+ i2c_stop(adap);
+ did_stop = true;
+ }
}
ret = i;
Support for enforced STOPs will allow us to use SCCB compatible devices. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> --- Notes: I don't actually have any SCCB compatible sensor but verified with a logic analyzer that repeated starts got replaced with a stop + start sequence. However, we have members in our team who might need this feature soon. I'll likely wait for their Tested-by unless something unforseen happens. drivers/i2c/algos/i2c-algo-bit.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)