rockchip: spi: only wait for completion, if transmitting
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Sun, 3 Feb 2019 15:17:30 +0000 (16:17 +0100)
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tue, 30 Apr 2019 22:00:04 +0000 (00:00 +0200)
commit7e0e5c552f2afcb9b6eeb2836232dfc4bbe29865
tree4ce5f74f2c64f79aa6f122200bcc91246b33d5fb
parentb6101e906f5afbb35d1980965f0633a3ca412616
rockchip: spi: only wait for completion, if transmitting

The logic in the main transmit loop took a bit of reading the TRM to
fully understand (due to silent assumptions based in internal logic):
the "wait until idle" at the end of each iteration through the loop is
required for the transmit-path as each clearing of the ENA register
(to update run-length in the CTRLR1 register) will implicitly flush
the FIFOs... transmisson can therefore not overlap loop iterations.

This change adds a comment to clarify the reason/need for waiting
until the controller becomes idle and wraps the entire check into an
'if (out)' to make it clear that this is required for transfers with a
transmit-component only (for transfers having a receive-component,
completion of the transmit-side is trivially ensured by having
received the correct number of bytes).

The change does not increase execution time measurably in any of my
tests.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
drivers/spi/rk_spi.c