Skip to content

Commit 83a3f1b

Browse files
Wolfram Sangbroonie
authored andcommitted
spi: sun6i: use 'time_left' variable with wait_for_completion_timeout()
There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Fix to the proper variable type 'unsigned long' while here. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: Jernej Skrabec <[email protected]> Reviewed-by: Andre Przywara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 34bed8a commit 83a3f1b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/spi/spi-sun6i.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ static int sun6i_spi_transfer_one(struct spi_controller *host,
277277
struct spi_transfer *tfr)
278278
{
279279
struct sun6i_spi *sspi = spi_controller_get_devdata(host);
280-
unsigned int div, div_cdr1, div_cdr2, timeout;
280+
unsigned int div, div_cdr1, div_cdr2;
281+
unsigned long time_left;
281282
unsigned int start, end, tx_time;
282283
unsigned int trig_level;
283284
unsigned int tx_len = 0, rx_len = 0, nbits = 0;
@@ -488,26 +489,26 @@ static int sun6i_spi_transfer_one(struct spi_controller *host,
488489

489490
tx_time = spi_controller_xfer_timeout(host, tfr);
490491
start = jiffies;
491-
timeout = wait_for_completion_timeout(&sspi->done,
492-
msecs_to_jiffies(tx_time));
492+
time_left = wait_for_completion_timeout(&sspi->done,
493+
msecs_to_jiffies(tx_time));
493494

494495
if (!use_dma) {
495496
sun6i_spi_drain_fifo(sspi);
496497
} else {
497-
if (timeout && rx_len) {
498+
if (time_left && rx_len) {
498499
/*
499500
* Even though RX on the peripheral side has finished
500501
* RX DMA might still be in flight
501502
*/
502-
timeout = wait_for_completion_timeout(&sspi->dma_rx_done,
503-
timeout);
504-
if (!timeout)
503+
time_left = wait_for_completion_timeout(&sspi->dma_rx_done,
504+
time_left);
505+
if (!time_left)
505506
dev_warn(&host->dev, "RX DMA timeout\n");
506507
}
507508
}
508509

509510
end = jiffies;
510-
if (!timeout) {
511+
if (!time_left) {
511512
dev_warn(&host->dev,
512513
"%s: timeout transferring %u bytes@%iHz for %i(%i)ms",
513514
dev_name(&spi->dev), tfr->len, tfr->speed_hz,

0 commit comments

Comments
 (0)