i2c: bcm2835: Protect against unexpected TXW/RXR interrupts
authorNoralf Trønnes <noralf@tronnes.org>
Fri, 23 Sep 2016 16:24:38 +0000 (18:24 +0200)
committerRaspbian kernel package updater <root@raspbian.org>
Sun, 8 Oct 2017 01:00:00 +0000 (01:00 +0000)
commit84902980b5014339d1faaeee637b99bd2d6e4ed5
tree06d271368d261f9d7cb212df5a2a5c921925bf9f
parentb5c74751d1253e6056d4fb07dcd41d7eadd0c842
i2c: bcm2835: Protect against unexpected TXW/RXR interrupts

If an unexpected TXW or RXR interrupt occurs (msg_buf_remaining == 0),
the driver has no way to fill/drain the FIFO to stop the interrupts.
In this case the controller has to be disabled and the transfer
completed to avoid hang.

(CLKT | ERR) and DONE interrupts are completed in their own paths, and
the controller is disabled in the transfer function after completion.
Unite the code paths and do disabling inside the interrupt routine.

Clear interrupt status bits in the united completion path instead of
trying to do it on every interrupt which isn't necessary.
Only CLKT, ERR and DONE can be cleared that way.

Add the status value to the error value in case of TXW/RXR errors to
distinguish them from the other S_LEN error.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
drivers/i2c/busses/i2c-bcm2835.c