Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <wsa+renesas@sang-engineering.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20240430114142.28551-8-wsa+renesas@sang-engineering.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Wolfram Sang and committed by
Mark Brown
83a3f1ba 34bed8a3

+9 -8
+9 -8
drivers/spi/spi-sun6i.c
··· 277 277 struct spi_transfer *tfr) 278 278 { 279 279 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; 281 282 unsigned int start, end, tx_time; 282 283 unsigned int trig_level; 283 284 unsigned int tx_len = 0, rx_len = 0, nbits = 0; ··· 489 488 490 489 tx_time = spi_controller_xfer_timeout(host, tfr); 491 490 start = jiffies; 492 - timeout = wait_for_completion_timeout(&sspi->done, 493 - msecs_to_jiffies(tx_time)); 491 + time_left = wait_for_completion_timeout(&sspi->done, 492 + msecs_to_jiffies(tx_time)); 494 493 495 494 if (!use_dma) { 496 495 sun6i_spi_drain_fifo(sspi); 497 496 } else { 498 - if (timeout && rx_len) { 497 + if (time_left && rx_len) { 499 498 /* 500 499 * Even though RX on the peripheral side has finished 501 500 * RX DMA might still be in flight 502 501 */ 503 - timeout = wait_for_completion_timeout(&sspi->dma_rx_done, 504 - timeout); 505 - if (!timeout) 502 + time_left = wait_for_completion_timeout(&sspi->dma_rx_done, 503 + time_left); 504 + if (!time_left) 506 505 dev_warn(&host->dev, "RX DMA timeout\n"); 507 506 } 508 507 } 509 508 510 509 end = jiffies; 511 - if (!timeout) { 510 + if (!time_left) { 512 511 dev_warn(&host->dev, 513 512 "%s: timeout transferring %u bytes@%iHz for %i(%i)ms", 514 513 dev_name(&spi->dev), tfr->len, tfr->speed_hz,