From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Elie Morisse <syniurge@gmail.com>,
Shyam Sundar S K <shyam-sundar.s-k@amd.com>,
Andi Shyti <andi.shyti@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 01/15] i2c: amd-mp2-plat: use 'time_left' variable with wait_for_completion_timeout()
Date: Sat, 27 Apr 2024 22:35:53 +0200 [thread overview]
Message-ID: <20240427203611.3750-2-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20240427203611.3750-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.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-amd-mp2-plat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c
index 112fe2bc5662..d3ac1c77a509 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-plat.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c
@@ -97,17 +97,17 @@ static void i2c_amd_cmd_completion(struct amd_i2c_common *i2c_common)
static int i2c_amd_check_cmd_completion(struct amd_i2c_dev *i2c_dev)
{
struct amd_i2c_common *i2c_common = &i2c_dev->common;
- unsigned long timeout;
+ unsigned long time_left;
- timeout = wait_for_completion_timeout(&i2c_dev->cmd_complete,
- i2c_dev->adap.timeout);
+ time_left = wait_for_completion_timeout(&i2c_dev->cmd_complete,
+ i2c_dev->adap.timeout);
if ((i2c_common->reqcmd == i2c_read ||
i2c_common->reqcmd == i2c_write) &&
i2c_common->msg->len > 32)
i2c_amd_dma_unmap(i2c_common);
- if (timeout == 0) {
+ if (time_left == 0) {
amd_mp2_rw_timeout(i2c_common);
return -ETIMEDOUT;
}
--
2.43.0
next prev parent reply other threads:[~2024-04-27 20:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 20:35 [PATCH 00/15] i2c: use 'time_left' with wait_for_* Wolfram Sang
2024-04-27 20:35 ` Wolfram Sang [this message]
2024-04-27 20:35 ` [PATCH 02/15] i2c: digicolor: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
2024-04-28 4:38 ` Baruch Siach
2024-04-27 20:35 ` [PATCH 03/15] i2c: exynos5: " Wolfram Sang
2024-04-27 20:35 ` [PATCH 04/15] i2c: hix5hd2: " Wolfram Sang
2024-04-27 20:35 ` [PATCH 05/15] i2c: imx-lpi2c: " Wolfram Sang
2024-04-28 1:45 ` Peng Fan
2024-04-27 20:35 ` [PATCH 06/15] i2c: omap: " Wolfram Sang
2024-04-27 20:35 ` [PATCH 07/15] i2c: st: " Wolfram Sang
2024-04-28 12:15 ` Uwe Kleine-König
2024-04-27 20:36 ` [PATCH 08/15] i2c: stm32f4: " Wolfram Sang
2024-04-27 20:36 ` [PATCH 09/15] i2c: stm32f7: " Wolfram Sang
2024-04-27 20:36 ` [PATCH 10/15] i2c: synquacer: " Wolfram Sang
2024-04-29 6:56 ` Ard Biesheuvel
2024-04-27 20:36 ` [PATCH 11/15] i2c: jz4780: " Wolfram Sang
2024-04-30 12:43 ` Philippe Mathieu-Daudé
2024-04-30 12:49 ` Paul Cercueil
2024-04-27 20:36 ` [PATCH 12/15] i2c: qcom-geni: " Wolfram Sang
2024-04-29 10:52 ` Bryan O'Donoghue
2024-04-30 2:10 ` Bjorn Andersson
2024-04-27 20:36 ` [PATCH 13/15] i2c: rk3x: use 'time_left' variable with wait_event_timeout() Wolfram Sang
2024-04-27 20:36 ` [PATCH 14/15] i2c: s3c2410: " Wolfram Sang
2024-04-27 20:36 ` [PATCH 15/15] i2c: pxa: " Wolfram Sang
2024-04-30 0:07 ` [PATCH 00/15] i2c: use 'time_left' with wait_for_* Andi Shyti
2024-05-02 11:29 ` Andi Shyti
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=20240427203611.3750-2-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=andi.shyti@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shyam-sundar.s-k@amd.com \
--cc=syniurge@gmail.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).