Skip to content

Commit 34bed8a

Browse files
Wolfram Sangbroonie
authored andcommitted
spi: sun4i: 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 e66480a commit 34bed8a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/spi/spi-sun4i.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ static int sun4i_spi_transfer_one(struct spi_controller *host,
206206
struct spi_transfer *tfr)
207207
{
208208
struct sun4i_spi *sspi = spi_controller_get_devdata(host);
209-
unsigned int mclk_rate, div, timeout;
209+
unsigned int mclk_rate, div;
210+
unsigned long time_left;
210211
unsigned int start, end, tx_time;
211212
unsigned int tx_len = 0;
212213
int ret = 0;
@@ -327,10 +328,10 @@ static int sun4i_spi_transfer_one(struct spi_controller *host,
327328

328329
tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U);
329330
start = jiffies;
330-
timeout = wait_for_completion_timeout(&sspi->done,
331-
msecs_to_jiffies(tx_time));
331+
time_left = wait_for_completion_timeout(&sspi->done,
332+
msecs_to_jiffies(tx_time));
332333
end = jiffies;
333-
if (!timeout) {
334+
if (!time_left) {
334335
dev_warn(&host->dev,
335336
"%s: timeout transferring %u bytes@%iHz for %i(%i)ms",
336337
dev_name(&spi->dev), tfr->len, tfr->speed_hz,

0 commit comments

Comments
 (0)