Skip to content

Commit af5a60b

Browse files
Jean DelvareJean Delvare
authored andcommitted
i2c-algo-bit: Complain about masters which can't read SCL
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable. Signed-off-by: Jean Delvare <khali@linux-fr.org>
1 parent f451171 commit af5a60b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎drivers/i2c/algos/i2c-algo-bit.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,10 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
604604
int (*add_adapter)(struct i2c_adapter *))
605605
{
606606
struct i2c_algo_bit_data *bit_adap = adap->algo_data;
607+
int ret;
607608

608609
if (bit_test) {
609-
int ret = test_bus(bit_adap, adap->name);
610+
ret = test_bus(bit_adap, adap->name);
610611
if (ret < 0)
611612
return -ENODEV;
612613
}
@@ -615,7 +616,16 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
615616
adap->algo = &i2c_bit_algo;
616617
adap->retries = 3;
617618

618-
return add_adapter(adap);
619+
ret = add_adapter(adap);
620+
if (ret < 0)
621+
return ret;
622+
623+
/* Complain if SCL can't be read */
624+
if (bit_adap->getscl == NULL) {
625+
dev_warn(&adap->dev, "Not I2C compliant: can't read SCL\n");
626+
dev_warn(&adap->dev, "Bus may be unreliable\n");
627+
}
628+
return 0;
619629
}
620630

621631
int i2c_bit_add_bus(struct i2c_adapter *adap)

0 commit comments

Comments
 (0)