diff options
author | Jon Lin <jon.lin@rock-chips.com> | 2020-07-23 03:43:56 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-07-28 19:29:31 +0300 |
commit | 4294e4accf8d695ea5605f6b189008b692e3e82c (patch) | |
tree | 23d9e35d64c40b52838f2cbfaec2d2a945fdecbf /drivers/spi | |
parent | 13a96935e6f66bafb6da92791120546a4bf20889 (diff) | |
download | linux-4294e4accf8d695ea5605f6b189008b692e3e82c.tar.xz |
spi: rockchip: Fix error in SPI slave pio read
The RXFLR is possible larger than rx_left in Rockchip SPI, fix it.
Fixes: 01b59ce5dac8 ("spi: rockchip: use irq rather than polling")
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Tested-by: Emil Renner Berthing <kernel@esmil.dk>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Emil Renner Berthing <kernel@esmil.dk>
Link: https://lore.kernel.org/r/20200723004356.6390-3-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-rockchip.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index a451dacab5cf..75a8a9428ff8 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -291,7 +291,7 @@ static void rockchip_spi_pio_writer(struct rockchip_spi *rs) static void rockchip_spi_pio_reader(struct rockchip_spi *rs) { 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 * level while spi is enabled, so instead make sure to leave |