[bootlin/training-materials updates] master: Add explanations about including defines for symbols defined in asm/<file>.h (aa7e3999)
Michael Opdenacker
michael.opdenacker at bootlin.com
Tue Oct 27 11:46:14 CET 2020
Repository : https://github.com/bootlin/training-materials
On branch : master
Link : https://github.com/bootlin/training-materials/commit/aa7e39990b798a380d1c46e713c7e17ca551919f
>---------------------------------------------------------------
commit aa7e39990b798a380d1c46e713c7e17ca551919f
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date: Tue Oct 27 11:46:14 2020 +0100
Add explanations about including defines for symbols defined in asm/<file>.h
Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>
>---------------------------------------------------------------
aa7e39990b798a380d1c46e713c7e17ca551919f
.../kernel-i2c-communication.tex | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/labs/kernel-i2c-communication/kernel-i2c-communication.tex b/labs/kernel-i2c-communication/kernel-i2c-communication.tex
index ecddba24..9f9b99a7 100644
--- a/labs/kernel-i2c-communication/kernel-i2c-communication.tex
+++ b/labs/kernel-i2c-communication/kernel-i2c-communication.tex
@@ -235,8 +235,24 @@ In the probe routine (run every time a matching device is found):
using. This could reveal communication issues. Using Elixir, find
examples of how to handle failures properly using the same
function.
+
\item Let the CPU wait for 1 ms by using the \kfunc{udelay} routine.
- You may need to use Elixir again to find the right C headers to include.
+ Let's use Elixir again to find the right C headers to include...
+
+ The Elixir results are a bit confusing here, because
+ \kfunc{udelay} is defined in \code{arch/<arch>/include/asm/delay.h} files,
+ but not in an \code{include/linux/<file>.h>} that is normally used
+ in kernel code.
+
+ However, look at \kfile{include/linux/delay.h} and you will see
+ that it includes \code{asm/delay.h} which corresponds to the
+ specific headers for the current architecture. So you need to include
+ \code{linux/delay.h}.
+
+ {\bf General rule}: whenever the symbol you're looking
+ for is defined in \code{arch/<arch>/include/asm/<file>.h}, you
+ can include \code{linux/<file>.h} in your kernel code.
+
\item In the same way, send the \code{0xfb} and \code{0x00} bytes now.
This completes the nunchuk initialization.
\end{enumerate}
More information about the training-materials-updates
mailing list