Skip to content

Commit 119f26f

Browse files
author
Codrin Ciubotariu
committed
i2c: at91: move i2c_recover_bus() outside of at91_do_twi_transfer()
This patch doesn't add a functional change, it just separates the recovery from the transfer itself. Fixes: d3d3fdc ("i2c: at91: implement i2c bus recovery") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
1 parent 3de043c commit 119f26f

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

drivers/i2c/busses/i2c-at91-master.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,6 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
640640
AT91_TWI_THRCLR | AT91_TWI_LOCKCLR);
641641
}
642642

643-
/*
644-
* some faulty I2C slave devices might hold SDA down;
645-
* we can send a bus clear command, hoping that the pins will be
646-
* released
647-
*/
648-
i2c_recover_bus(&dev->adapter);
649-
650643
return ret;
651644
}
652645

@@ -706,7 +699,17 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
706699

707700
ret = at91_do_twi_transfer(dev);
708701

709-
ret = (ret < 0) ? ret : num;
702+
if (ret < 0) {
703+
/*
704+
* some faulty I2C slave devices might hold SDA down;
705+
* we can send a bus clear command, hoping that the pins will be
706+
* released
707+
*/
708+
i2c_recover_bus(&dev->adapter);
709+
} else {
710+
ret = num;
711+
}
712+
710713
out:
711714
pm_runtime_mark_last_busy(dev->dev);
712715
pm_runtime_put_autosuspend(dev->dev);

0 commit comments

Comments
 (0)