linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-spi@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 8/8] spi: xlp: use 'time_left' variable with wait_for_completion_timeout()
Date: Mon, 29 Apr 2024 13:28:41 +0200	[thread overview]
Message-ID: <20240429112843.67628-9-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com>

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>
---
 drivers/spi/spi-xlp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-xlp.c b/drivers/spi/spi-xlp.c
index 49302364b7bd..2fec18b68449 100644
--- a/drivers/spi/spi-xlp.c
+++ b/drivers/spi/spi-xlp.c
@@ -270,7 +270,7 @@ static int xlp_spi_xfer_block(struct  xlp_spi_priv *xs,
 		const unsigned char *tx_buf,
 		unsigned char *rx_buf, int xfer_len, int cmd_cont)
 {
-	int timeout;
+	unsigned long time_left;
 	u32 intr_mask = 0;
 
 	xs->tx_buf = tx_buf;
@@ -299,11 +299,11 @@ static int xlp_spi_xfer_block(struct  xlp_spi_priv *xs,
 	intr_mask |= XLP_SPI_INTR_DONE;
 	xlp_spi_reg_write(xs, xs->cs, XLP_SPI_INTR_EN, intr_mask);
 
-	timeout = wait_for_completion_timeout(&xs->done,
-				msecs_to_jiffies(1000));
+	time_left = wait_for_completion_timeout(&xs->done,
+						msecs_to_jiffies(1000));
 	/* Disable interrupts */
 	xlp_spi_reg_write(xs, xs->cs, XLP_SPI_INTR_EN, 0x0);
-	if (!timeout) {
+	if (!time_left) {
 		dev_err(&xs->dev, "xfer timedout!\n");
 		goto out;
 	}
-- 
2.43.0


  parent reply	other threads:[~2024-04-29 11:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 11:28 [PATCH 0/8] spi: use 'time_left' instead of 'timeout' with wait_for_*() functions Wolfram Sang
2024-04-29 11:28 ` [PATCH 1/8] spi: armada-3700: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
2024-04-29 15:15   ` Mark Brown
2024-04-29 11:28 ` [PATCH 2/8] spi: fsl-lpspi: " Wolfram Sang
2024-04-29 11:28 ` [PATCH 3/8] spi: imx: " Wolfram Sang
2024-04-30  1:35   ` Peng Fan
2024-04-29 11:28 ` [PATCH 4/8] spi: pic32-sqi: " Wolfram Sang
2024-04-29 11:28 ` [PATCH 5/8] spi: pic32: " Wolfram Sang
2024-04-29 11:28 ` [PATCH 6/8] spi: sun4i: " Wolfram Sang
2024-04-29 12:14   ` Andre Przywara
2024-04-29 15:19   ` Jernej Škrabec
2024-04-29 11:28 ` [PATCH 7/8] spi: sun6i: " Wolfram Sang
2024-04-29 12:16   ` Andre Przywara
2024-04-29 14:36     ` Wolfram Sang
2024-04-29 15:20   ` Jernej Škrabec
2024-04-29 11:28 ` Wolfram Sang [this message]
2024-05-02  3:57 ` [PATCH 0/8] spi: use 'time_left' instead of 'timeout' with wait_for_*() functions Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240429112843.67628-9-wsa+renesas@sang-engineering.com \
    --to=wsa+renesas@sang-engineering.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).