Skip to content

Commit 61bf40e

Browse files
Eddie Jamesbroonie
authored andcommitted
spi: fsi: Fix spurious timeout
The driver may return a timeout error even if the status register indicates that the transfer may proceed. Fix this by restructuring the polling loop. Fixes: 89b35e3 ("spi: fsi: Implement a timeout for polling status") Signed-off-by: Eddie James <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9c63b84 commit 61bf40e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/spi/spi-fsi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx,
319319

320320
end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS);
321321
do {
322+
if (time_after(jiffies, end))
323+
return -ETIMEDOUT;
324+
322325
rc = fsi_spi_status(ctx, &status, "TX");
323326
if (rc)
324327
return rc;
325-
326-
if (time_after(jiffies, end))
327-
return -ETIMEDOUT;
328328
} while (status & SPI_FSI_STATUS_TDR_FULL);
329329

330330
sent += nb;
@@ -337,12 +337,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx,
337337
while (transfer->len > recv) {
338338
end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS);
339339
do {
340+
if (time_after(jiffies, end))
341+
return -ETIMEDOUT;
342+
340343
rc = fsi_spi_status(ctx, &status, "RX");
341344
if (rc)
342345
return rc;
343-
344-
if (time_after(jiffies, end))
345-
return -ETIMEDOUT;
346346
} while (!(status & SPI_FSI_STATUS_RDR_FULL));
347347

348348
rc = fsi_spi_read_reg(ctx, SPI_FSI_DATA_RX, &in);

0 commit comments

Comments
 (0)