LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: "Pavel Machek" <pavel@ucw.cz>,
"Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Amireddy Mallikarjuna reddy"
<mallikarjunax.reddy@linux.intel.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Abanoub Sameh" <abanoubsameh8@gmail.com>,
"Marek Behún" <marek.behun@nic.cz>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 02/13] leds: el15203000: Give better margin for usleep_range()
Date: Sat, 29 May 2021 14:19:24 +0300 [thread overview]
Message-ID: <20210529111935.3849707-2-andy.shevchenko@gmail.com> (raw)
In-Reply-To: <20210529111935.3849707-1-andy.shevchenko@gmail.com>
1 microsecond with 20 millisecond parameter is too low margin for
usleep_range(). Give 100 to make scheduler been less tortured.
While at it, fix indentation in cases where EL_FW_DELAY_USEC is in use.
In the loop, move it to the end to avoid a conditional.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
v2: amended the commit message
drivers/leds/leds-el15203000.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c
index 76b455e87574..77e76f775385 100644
--- a/drivers/leds/leds-el15203000.c
+++ b/drivers/leds/leds-el15203000.c
@@ -97,27 +97,22 @@ static int el15203000_cmd(struct el15203000_led *led, u8 brightness)
/* to avoid SPI mistiming with firmware we should wait some time */
if (time_after(led->priv->delay, jiffies)) {
- dev_dbg(led->priv->dev, "Wait %luus to sync",
- EL_FW_DELAY_USEC);
+ dev_dbg(led->priv->dev, "Wait %luus to sync", EL_FW_DELAY_USEC);
- usleep_range(EL_FW_DELAY_USEC,
- EL_FW_DELAY_USEC + 1);
+ usleep_range(EL_FW_DELAY_USEC, EL_FW_DELAY_USEC + 100);
}
cmd[0] = led->reg;
cmd[1] = brightness;
for (i = 0; i < ARRAY_SIZE(cmd); i++) {
- if (i)
- usleep_range(EL_FW_DELAY_USEC,
- EL_FW_DELAY_USEC + 1);
-
ret = spi_write(led->priv->spi, &cmd[i], sizeof(cmd[i]));
if (ret) {
dev_err(led->priv->dev,
"spi_write() error %d", ret);
break;
}
+ usleep_range(EL_FW_DELAY_USEC, EL_FW_DELAY_USEC + 100);
}
led->priv->delay = jiffies + usecs_to_jiffies(EL_FW_DELAY_USEC);
@@ -306,8 +301,7 @@ static int el15203000_probe(struct spi_device *spi)
priv->count = count;
priv->dev = &spi->dev;
priv->spi = spi;
- priv->delay = jiffies -
- usecs_to_jiffies(EL_FW_DELAY_USEC);
+ priv->delay = jiffies - usecs_to_jiffies(EL_FW_DELAY_USEC);
spi_set_drvdata(spi, priv);
--
2.31.1
next prev parent reply other threads:[~2021-05-29 11:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-29 11:19 [PATCH v2 01/13] leds: core: The -ENOTSUPP should never be seen by user space Andy Shevchenko
2021-05-29 11:19 ` Andy Shevchenko [this message]
2021-05-29 11:19 ` [PATCH v2 03/13] leds: el15203000: Correct headers (of*.h -> mod_devicetable.h) Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 04/13] leds: lgm-sso: Put fwnode in any case during ->probe() Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 05/13] leds: lgm-sso: Don't spam logs when probe is deferred Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 06/13] leds: lgm-sso: Remove explicit managed GPIO resource cleanup Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 07/13] leds: lgm-sso: Convert to use list_for_each_entry*() API Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 08/13] leds: lm3692x: Correct headers (of*.h -> mod_devicetable.h) Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 09/13] leds: lm3697: Update header block to reflect reality Andy Shevchenko
2021-08-03 21:47 ` Pavel Machek
2021-05-29 11:19 ` [PATCH v2 10/13] leds: lm3697: Make error handling more robust Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 11/13] leds: lt3593: Put fwnode in any case during ->probe() Andy Shevchenko
2021-05-29 11:19 ` [PATCH v2 12/13] leds: rt8515: " Andy Shevchenko
2021-06-01 10:06 ` Linus Walleij
2021-06-05 9:46 ` andy
2021-08-03 21:50 ` Pavel Machek
2021-08-03 21:51 ` Pavel Machek
2021-05-29 11:19 ` [PATCH v2 13/13] leds: sgm3140: " Andy Shevchenko
2021-06-23 13:15 ` [PATCH v2 01/13] leds: core: The -ENOTSUPP should never be seen by user space Andy Shevchenko
2021-07-13 7:34 ` Andy Shevchenko
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=20210529111935.3849707-2-andy.shevchenko@gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=abanoubsameh8@gmail.com \
--cc=krzk@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mallikarjunax.reddy@linux.intel.com \
--cc=marek.behun@nic.cz \
--cc=pavel@ucw.cz \
--subject='Re: [PATCH v2 02/13] leds: el15203000: Give better margin for usleep_range()' \
/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
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).