[bootlin/training-materials updates] master: Kernel labs: make reg_write/reg_read prototypes more explicit (2ab8f463)

Michael Opdenacker michael.opdenacker at bootlin.com
Thu Apr 22 17:12:43 CEST 2021


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

>---------------------------------------------------------------

commit 2ab8f463f9d0c66abc7d5345edc2c1da2fb3b746
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Thu Apr 22 17:12:43 2021 +0200

    Kernel labs: make reg_write/reg_read prototypes more explicit
    
    - Using "reg" instead of "offset" is more explicit
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>
    Reported-by: Sascha Schröder <s.schroeder at avm.de>


>---------------------------------------------------------------

2ab8f463f9d0c66abc7d5345edc2c1da2fb3b746
 labs/kernel-serial-iomem/kernel-serial-iomem.tex | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/labs/kernel-serial-iomem/kernel-serial-iomem.tex b/labs/kernel-serial-iomem/kernel-serial-iomem.tex
index 9f768879..f4e20ab6 100644
--- a/labs/kernel-serial-iomem/kernel-serial-iomem.tex
+++ b/labs/kernel-serial-iomem/kernel-serial-iomem.tex
@@ -171,25 +171,30 @@ devices. Of course, this will be done in the \code{probe()} routine.
 \subsection{Accessing device registers}
 
 As we will have multiple registers to read, create a \code{reg_read()}
-routine, returning an \code{unsigned int} value, and  taking a \code{dev}
-pointer to an \code{serial_dev} structure and an \code{offset} integer
+routine, returning an \code{unsigned int} value, and taking a \code{dev}
+pointer to an \code{serial_dev} structure and an \code{int} register
 offset.
 
+Your prototype should look like:
+\begin{verbatim}
+static void reg_read(struct serial_dev *dev, int reg);
+\end{verbatim}
+
 In this function, read from a 32 bits register at the base virtual
-address for the device plus the offset multiplied by 4.
+address for the device plus the register offset multiplied by 4.
 
 All the UART register offsets have standardized values, shared between
 several types of serial drivers (see
 \kfile{include/uapi/linux/serial_reg.h}). This explains why they are not
 completely ready to use and we have to multiply them by 4 for OMAP SoCs.
 
-Create a similar \code{reg_write()} routine, writing an unsigned integer
-value at a given integer offset (don't forget to multiply it by 4) from
+Create a similar \code{reg_write()} routine, writing an \code{int}
+value at a given register offset (don't forget to multiply it by 4) from
 the device base virtual address. The following code samples are using
 the \kfunc{writel} convention of passing the value first, then the
 offset. Your prototype should look like:
 \begin{verbatim}
-static void reg_write(struct serial_dev *dev, int val, int off);
+static void reg_write(struct serial_dev *dev, int val, int reg);
 \end{verbatim}
 
 In the next sections, we will tell you what register offsets to use




More information about the training-materials-updates mailing list