[bootlin/training-materials updates] master: Kernel labs: restore the use of usleep_range(), with correct values (1dfb2e3f)

Michael Opdenacker michael.opdenacker at bootlin.com
Fri Oct 23 17:17:49 CEST 2020

Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/1dfb2e3fd5f1d4fc3388d436c8c5b0c998f43238


commit 1dfb2e3fd5f1d4fc3388d436c8c5b0c998f43238
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Fri Oct 23 17:17:49 2020 +0200

    Kernel labs: restore the use of usleep_range(), with correct values
    - It didn't work before because when we switched to this
      function, we forgot to convert the milliseconds into microseconds!
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>


 labs/kernel-i2c-communication/kernel-i2c-communication.tex | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/labs/kernel-i2c-communication/kernel-i2c-communication.tex b/labs/kernel-i2c-communication/kernel-i2c-communication.tex
index 386178d1..ecddba24 100644
--- a/labs/kernel-i2c-communication/kernel-i2c-communication.tex
+++ b/labs/kernel-i2c-communication/kernel-i2c-communication.tex
@@ -257,7 +257,12 @@ In this function:
 \item Start by putting a \code{10 ms} delay by calling
-      \code{msleep(10)}.
+      \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.
+      You'll find interesting details on how to sleep or wait in kernel
+      code for specified durations in the kernel documentation:
+      \kerneldochtml{timers/timers-howto}.}
       Such waiting time is needed to add time between the previous i2c
       operation and the next one.
 \item Write \code{0x00} to the bus. That will allow us to read

More information about the training-materials-updates mailing list