Commit 68a16708 authored by Ben Dooks's avatar Ben Dooks Committed by Mark Brown

spi: s3c64xx: fix timeout counters in flush_fifo

In the s3c64xx_flush_fifo() code, the loops counter is post-decremented
in the do { } while(test && loops--) condition. This means the loops is
left at the unsigned equivalent of -1 if the loop times out. The test
after will never pass as if tests for loops == 0.
Signed-off-by: default avatarBen Dooks <ben.dooks@codethink.co.uk>
Fixes: 230d42d4 ("spi: Add s3c64xx SPI Controller driver")
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20240924134009.116247-2-ben.dooks@codethink.co.ukSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 162d9b5d
...@@ -245,7 +245,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) ...@@ -245,7 +245,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd)
loops = msecs_to_loops(1); loops = msecs_to_loops(1);
do { do {
val = readl(regs + S3C64XX_SPI_STATUS); val = readl(regs + S3C64XX_SPI_STATUS);
} while (TX_FIFO_LVL(val, sdd) && loops--); } while (TX_FIFO_LVL(val, sdd) && --loops);
if (loops == 0) if (loops == 0)
dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n"); dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n");
...@@ -258,7 +258,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) ...@@ -258,7 +258,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd)
readl(regs + S3C64XX_SPI_RX_DATA); readl(regs + S3C64XX_SPI_RX_DATA);
else else
break; break;
} while (loops--); } while (--loops);
if (loops == 0) if (loops == 0)
dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n"); dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n");
......
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