public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Joshua Crofts via B4 Relay <devnull+joshua.crofts1.gmail.com@kernel.org>
Cc: joshua.crofts1@gmail.com, "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Jean-Francois Dagenais" <jeff.dagenais@gmail.com>,
	"Maxime Roussin-Bélanger" <maxime.roussinbelanger@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 7/8] iio: light: si1133: add local variable for timeout
Date: Tue, 5 May 2026 13:30:22 +0100	[thread overview]
Message-ID: <20260505133022.1e7a0f71@jic23-huawei> (raw)
In-Reply-To: <20260505-si1133-checkup-v5-7-5df86a9024ed@gmail.com>

On Tue, 05 May 2026 09:31:32 +0200
Joshua Crofts via B4 Relay <devnull+joshua.crofts1.gmail.com@kernel.org> wrote:

> From: Joshua Crofts <joshua.crofts1@gmail.com>
> 
> Add local variable for timeout to improve readability.
> 
> No functional change.
> 
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Tweaked as I mentioned in my late reply to v4 thread.

diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c
index a3e4ab25acdc..ef5c38e303a6 100644
--- a/drivers/iio/light/si1133.c
+++ b/drivers/iio/light/si1133.c
@@ -390,7 +390,7 @@ static int si1133_cmd_reset_counter(struct si1133_data *data)
 
 static int si1133_command(struct si1133_data *data, u8 cmd)
 {
-       unsigned long timeout = msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS);
+       unsigned long timeout;
        struct device *dev = &data->client->dev;
        u32 resp;
        int err;
@@ -418,6 +418,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd)
 
        if (cmd == SI1133_CMD_FORCE) {
                /* wait for irq */
+               timeout = msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS);
                if (!wait_for_completion_timeout(&data->completion, timeout)) {
                        regmap_write(data->regmap, SI1133_REG_IRQ_ENABLE, 0);
                        err = -ETIMEDOUT;


> ---
>  drivers/iio/light/si1133.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c
> index fdffdee16e493277d95c369ec2f6c0678cf9f61c..a3e4ab25acdc105d3800994f4391a7e4291e1c74 100644
> --- a/drivers/iio/light/si1133.c
> +++ b/drivers/iio/light/si1133.c
> @@ -390,6 +390,7 @@ static int si1133_cmd_reset_counter(struct si1133_data *data)
>  
>  static int si1133_command(struct si1133_data *data, u8 cmd)
>  {
> +	unsigned long timeout = msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS);
>  	struct device *dev = &data->client->dev;
>  	u32 resp;
>  	int err;
> @@ -417,8 +418,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd)
>  
>  	if (cmd == SI1133_CMD_FORCE) {
>  		/* wait for irq */
> -		if (!wait_for_completion_timeout(&data->completion,
> -			msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS))) {
> +		if (!wait_for_completion_timeout(&data->completion, timeout)) {
>  			regmap_write(data->regmap, SI1133_REG_IRQ_ENABLE, 0);
>  			err = -ETIMEDOUT;
>  			goto out;
> 


  reply	other threads:[~2026-05-05 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05  7:31 [PATCH v5 0/8] iio: light: si1133: driver cleanup Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 1/8] iio: light: si1133: reset counter to prevent race condition Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 2/8] iio: light: si1133: prevent race condition on timeout Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 3/8] iio: light: si1133: remove unused macros Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 4/8] iio: light: si1133: prefer complex macros enclosed in parenthesis Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 5/8] iio: light: si1133: add missing include headers Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 6/8] iio: light: si1133: group generic <linux/*> headers Joshua Crofts via B4 Relay
2026-05-05  7:31 ` [PATCH v5 7/8] iio: light: si1133: add local variable for timeout Joshua Crofts via B4 Relay
2026-05-05 12:30   ` Jonathan Cameron [this message]
2026-05-05  7:31 ` [PATCH v5 8/8] iio: light: si1133: use guard(mutex)() macro Joshua Crofts via B4 Relay
2026-05-05 12:34 ` [PATCH v5 0/8] iio: light: si1133: driver cleanup Jonathan Cameron
2026-05-05 14:05   ` Joshua Crofts

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=20260505133022.1e7a0f71@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=devnull+joshua.crofts1.gmail.com@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jeff.dagenais@gmail.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.roussinbelanger@gmail.com \
    --cc=nuno.sa@analog.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