]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: s3c64xx: fix timeout counters in flush_fifo
authorBen Dooks <ben.dooks@codethink.co.uk>
Tue, 24 Sep 2024 13:40:08 +0000 (14:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2024 10:00:41 +0000 (12:00 +0200)
[ Upstream commit 68a16708d2503b6303d67abd43801e2ca40c208d ]

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: Ben Dooks <ben.dooks@codethink.co.uk>
Fixes: 230d42d422e7 ("spi: Add s3c64xx SPI Controller driver")
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20240924134009.116247-2-ben.dooks@codethink.co.uk
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-s3c64xx.c

index 833c58c88e4086cf8761520df8b6db637eee1794..6ab416a3396690ad6fd96da32085b6c4ed901b96 100644 (file)
@@ -245,7 +245,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd)
        loops = msecs_to_loops(1);
        do {
                val = readl(regs + S3C64XX_SPI_STATUS);
-       } while (TX_FIFO_LVL(val, sdd) && loops--);
+       } while (TX_FIFO_LVL(val, sdd) && --loops);
 
        if (loops == 0)
                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)
                        readl(regs + S3C64XX_SPI_RX_DATA);
                else
                        break;
-       } while (loops--);
+       } while (--loops);
 
        if (loops == 0)
                dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n");