thermal: armada: replace msleep with usleep_range for short durations
Subsystems (2)
PATCH 1/1 thermal: armada: replace msleep with usleep_range for short durations
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.
--- drivers/thermal/armada_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/armada_thermal.c +1 -1
@@ -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,
Signature · 1 line
2.34.1
Quoted 9 lines · 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 <[email protected]>---
Miquel,
if you are not against this change, I'll pick it up
Thanks
Quoted 16 lines
drivers/thermal/armada_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/armada_thermal.c +1
-1@@ -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,
Miquel Raynal
maintainerHello Mayur, Daniel,
Actually I have a couple of comments :-)
Quoted 2 lines · Daniel Lezcano
Quoted 1 line · Mayur Kumar
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.
Quoted 1 line
Quoted 1 line
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")
Quoted 2 lines
Quoted 2 lines
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?
Quoted 1 line
Quoted 1 line
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