[bootlin/training-materials updates] master: kernel: i2c-comm: explain why usleep_range() should be used (0dd17f28)
Clément Léger
clement.leger at bootlin.com
Tue Jun 21 11:47:05 CEST 2022
Repository : https://github.com/bootlin/training-materials
On branch : master
Link : https://github.com/bootlin/training-materials/commit/0dd17f28a2ce65beb9a946f621020448c54b5a83
>---------------------------------------------------------------
commit 0dd17f28a2ce65beb9a946f621020448c54b5a83
Author: Clément Léger <clement.leger at bootlin.com>
Date: Tue Jun 21 11:43:50 2022 +0200
kernel: i2c-comm: explain why usleep_range() should be used
There is no real explanation why usleep_range() should be used rather
than a simple usleep(). Add some text to clarify that's it's more
efficient if wait time is flexible.
Signed-off-by: Clément Léger <clement.leger at bootlin.com>
>---------------------------------------------------------------
0dd17f28a2ce65beb9a946f621020448c54b5a83
labs/kernel-i2c-communication/kernel-i2c-communication.tex | 3 +++
1 file changed, 3 insertions(+)
diff --git a/labs/kernel-i2c-communication/kernel-i2c-communication.tex b/labs/kernel-i2c-communication/kernel-i2c-communication.tex
index 8e097ad1..68768c6c 100644
--- a/labs/kernel-i2c-communication/kernel-i2c-communication.tex
+++ b/labs/kernel-i2c-communication/kernel-i2c-communication.tex
@@ -285,6 +285,9 @@ In this function:
\code{usleep_range(10000, 20000)}, guaranteed to sleep between 10 and 20
ms.\footnote{That's better than using \kfunc{udelay} because it is not making
an active wait, and instead lets the CPU run other tasks in the meantime.
+ Moreover, this is better than using \kfunc{usleep} if your wait time is
+ flexible because this function will try to group tasks wakeup rather than
+ creating a specific timer to wake up that task.
You'll find interesting details on how to sleep or wait in kernel
code for specified durations in the kernel documentation:
\kdochtml{timers/timers-howto}.}
More information about the training-materials-updates
mailing list