* [PATCH] thermal: armada: replace msleep with usleep_range for short durations
@ 2026-05-11 15:37 Mayur Kumar
2026-05-18 17:57 ` Daniel Lezcano
0 siblings, 1 reply; 3+ messages in thread
From: Mayur Kumar @ 2026-05-11 15:37 UTC (permalink / raw)
To: miquel.raynal, rafael, daniel.lezcano, rui.zhang, lukasz.luba
Cc: linux-pm, linux-kernel, Mayur Kumar
The checkpatch tool warns that msleep(10) can sleep for up to 20ms.
According to Documentation/timers/timers-howto.rst, usleep_range()
should be used for delays between 1ms and 20ms to provide better
timing accuracy.
Replace the 10ms msleep with a 10ms-11ms usleep_range.
Signed-off-by: Mayur Kumar <kmayur809@gmail.com>
---
drivers/thermal/armada_thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index c2fbdb534f6..96965f393b4 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -178,7 +178,7 @@ static void armada370_init(struct platform_device *pdev,
regmap_write(priv->syscon, data->syscon_control1_off, reg);
- msleep(10);
+ usleep_range(10000, 11000);
}
static void armada375_init(struct platform_device *pdev,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: armada: replace msleep with usleep_range for short durations
2026-05-11 15:37 [PATCH] thermal: armada: replace msleep with usleep_range for short durations Mayur Kumar
@ 2026-05-18 17:57 ` Daniel Lezcano
2026-05-19 7:43 ` Miquel Raynal
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2026-05-18 17:57 UTC (permalink / raw)
To: Mayur Kumar, miquel.raynal, rafael, daniel.lezcano, rui.zhang,
lukasz.luba
Cc: linux-pm, linux-kernel
On 5/11/26 17:37, Mayur Kumar wrote:
> The checkpatch tool warns that msleep(10) can sleep for up to 20ms.
> According to Documentation/timers/timers-howto.rst, usleep_range()
> should be used for delays between 1ms and 20ms to provide better
> timing accuracy.
>
> Replace the 10ms msleep with a 10ms-11ms usleep_range.
>
> Signed-off-by: Mayur Kumar <kmayur809@gmail.com>
> ---
Miquel,
if you are not against this change, I'll pick it up
Thanks
> drivers/thermal/armada_thermal.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index c2fbdb534f6..96965f393b4 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -178,7 +178,7 @@ static void armada370_init(struct platform_device *pdev,
>
> regmap_write(priv->syscon, data->syscon_control1_off, reg);
>
> - msleep(10);
> + usleep_range(10000, 11000);
> }
>
> static void armada375_init(struct platform_device *pdev,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: armada: replace msleep with usleep_range for short durations
2026-05-18 17:57 ` Daniel Lezcano
@ 2026-05-19 7:43 ` Miquel Raynal
0 siblings, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2026-05-19 7:43 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Mayur Kumar, rafael, daniel.lezcano, rui.zhang, lukasz.luba,
linux-pm, linux-kernel
Hello Mayur, Daniel,
Actually I have a couple of comments :-)
On 18/05/2026 at 19:57:46 +02, Daniel Lezcano <daniel.lezcano@oss.qualcomm.com> wrote:
> On 5/11/26 17:37, Mayur Kumar wrote:
>> The checkpatch tool warns that msleep(10) can sleep for up to 20ms.
This is a tool that gives you raw advices. Is sleeping 20ms a problem in
an init function, clearly outside of any hotpath? Honestly that does not
look like a big issue to me.
>> According to Documentation/timers/timers-howto.rst, usleep_range()
This file has been dropped in favour of a more up-to-date
Documentation/timers/delay_sleep_functions.rst in:
1f455f601e20 ("timers/Documentation: Cleanup delay/sleep documentation")
>> should be used for delays between 1ms and 20ms to provide better
>> timing accuracy.
Again, I don't see the point here, we do not need accuracy, do we?
>> Replace the 10ms msleep with a 10ms-11ms usleep_range.
10 to 11ms feels very arbitrary and has been selected just for getting
the tool happy. The above file states:
#. Use `fsleep()` whenever unsure (as it combines all the advantages of the
others)
#. Use `*sleep()` whenever possible
#. Use `usleep_range*()` whenever accuracy of `*sleep()` is not sufficient
#. Use `*delay()` for very, very short delays
Accuracy not being a concern here, fsleep() could be the way to go, and
the actual implementation would end up being usleep_range(10000, 20000),
which is exactly what the tool complains about.
In general I would be in favour of avoiding this kind of change that is
not motivated by hardware concerns, but if you really want to fix this
checkpatch.pl warning I believe in such case you should go for an
fsleep().
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-19 7:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 15:37 [PATCH] thermal: armada: replace msleep with usleep_range for short durations Mayur Kumar
2026-05-18 17:57 ` Daniel Lezcano
2026-05-19 7:43 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox