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

spi: xlp: 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>
Link: https://lore.kernel.org/r/20240430114142.28551-9-wsa+renesas@sang-engineering.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Wolfram Sang and committed by
Mark Brown
594aa75d 83a3f1ba

+4 -4
+4 -4
drivers/spi/spi-xlp.c
··· 270 270 const unsigned char *tx_buf, 271 271 unsigned char *rx_buf, int xfer_len, int cmd_cont) 272 272 { 273 - int timeout; 273 + unsigned long time_left; 274 274 u32 intr_mask = 0; 275 275 276 276 xs->tx_buf = tx_buf; ··· 299 299 intr_mask |= XLP_SPI_INTR_DONE; 300 300 xlp_spi_reg_write(xs, xs->cs, XLP_SPI_INTR_EN, intr_mask); 301 301 302 - timeout = wait_for_completion_timeout(&xs->done, 303 - msecs_to_jiffies(1000)); 302 + time_left = wait_for_completion_timeout(&xs->done, 303 + msecs_to_jiffies(1000)); 304 304 /* Disable interrupts */ 305 305 xlp_spi_reg_write(xs, xs->cs, XLP_SPI_INTR_EN, 0x0); 306 - if (!timeout) { 306 + if (!time_left) { 307 307 dev_err(&xs->dev, "xfer timedout!\n"); 308 308 goto out; 309 309 }