lkml.org 
[lkml]   [2021]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 02/13] leds: el15203000: Give better margin for usleep_range()
Date
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
\
 
 \ /
  Last update: 2021-05-29 13:20    [W:0.290 / U:1.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site