Commit 4294e4ac authored by Jon Lin's avatar Jon Lin Committed by Mark Brown

spi: rockchip: Fix error in SPI slave pio read

The RXFLR is possible larger than rx_left in Rockchip SPI, fix it.

Fixes: 01b59ce5 ("spi: rockchip: use irq rather than polling")
Signed-off-by: default avatarJon Lin <jon.lin@rock-chips.com>
Tested-by: default avatarEmil Renner Berthing <kernel@esmil.dk>
Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
Reviewed-by: default avatarEmil Renner Berthing <kernel@esmil.dk>
Link: https://lore.kernel.org/r/20200723004356.6390-3-jon.lin@rock-chips.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 13a96935
...@@ -291,7 +291,7 @@ static void rockchip_spi_pio_writer(struct rockchip_spi *rs) ...@@ -291,7 +291,7 @@ static void rockchip_spi_pio_writer(struct rockchip_spi *rs)
static void rockchip_spi_pio_reader(struct rockchip_spi *rs) static void rockchip_spi_pio_reader(struct rockchip_spi *rs)
{ {
u32 words = readl_relaxed(rs->regs + ROCKCHIP_SPI_RXFLR); u32 words = readl_relaxed(rs->regs + ROCKCHIP_SPI_RXFLR);
u32 rx_left = rs->rx_left - words; u32 rx_left = (rs->rx_left > words) ? rs->rx_left - words : 0;
/* the hardware doesn't allow us to change fifo threshold /* the hardware doesn't allow us to change fifo threshold
* level while spi is enabled, so instead make sure to leave * level while spi is enabled, so instead make sure to leave
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment