Skip to content

Commit c8bce81

Browse files
6by9popcornmix
authored andcommitted
i2c-bcm2835: Implement I2C_M_IGNORE_NAK
Now that transfers aren't aborted immediately (and uncleanly) on errors, and the FIFOs are always drained after all transfers, we can implement I2C_M_IGNORE_NAK by ignoring the returned error value. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 39df28b commit c8bce81

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/i2c/busses/i2c-bcm2835.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
443443
{
444444
struct bcm2835_i2c_dev *i2c_dev = i2c_get_adapdata(adap);
445445
unsigned long time_left;
446+
bool ignore_nak = false;
446447
int i;
447448

448449
if (debug)
@@ -452,12 +453,15 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
452453
for (i = 0; i < num; i++)
453454
bcm2835_debug_print_msg(i2c_dev, &msgs[i], i + 1, num, __func__);
454455

455-
for (i = 0; i < (num - 1); i++)
456+
for (i = 0; i < (num - 1); i++) {
456457
if (msgs[i].flags & I2C_M_RD) {
457458
dev_warn_once(i2c_dev->dev,
458459
"only one read message supported, has to be last\n");
459460
return -EOPNOTSUPP;
460461
}
462+
if (msgs[i].flags & I2C_M_IGNORE_NAK)
463+
ignore_nak = true;
464+
}
461465

462466
i2c_dev->curr_msg = msgs;
463467
i2c_dev->num_msgs = num;
@@ -471,6 +475,9 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
471475

472476
bcm2835_i2c_finish_transfer(i2c_dev);
473477

478+
if (ignore_nak)
479+
i2c_dev->msg_err &= ~BCM2835_I2C_S_ERR;
480+
474481
if (debug > 1 || (debug && (!time_left || i2c_dev->msg_err)))
475482
bcm2835_debug_print(i2c_dev);
476483
i2c_dev->debug_num_msgs = 0;
@@ -497,7 +504,7 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
497504

498505
static u32 bcm2835_i2c_func(struct i2c_adapter *adap)
499506
{
500-
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
507+
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
501508
}
502509

503510
static const struct i2c_algorithm bcm2835_i2c_algo = {

0 commit comments

Comments
 (0)