[bootlin/training-materials updates] master: Kernel labs: fix instructions after previous change (7c58157c)

Thomas Petazzoni thomas.petazzoni at bootlin.com
Fri Oct 29 10:46:36 CEST 2021

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


commit 7c58157c269dde4938ccd467a56bb6ab8db42107
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Mon Apr 26 16:03:41 2021 +0200

    Kernel labs: fix instructions after previous change
    - After the switch to devm_platform_ioremap_resource
      we no longer have a *resource pointer readily available.
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>


 labs/kernel-serial-output/kernel-serial-output.tex | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/labs/kernel-serial-output/kernel-serial-output.tex b/labs/kernel-serial-output/kernel-serial-output.tex
index 16a6a900..f14f838b 100644
--- a/labs/kernel-serial-output/kernel-serial-output.tex
+++ b/labs/kernel-serial-output/kernel-serial-output.tex
@@ -64,8 +64,13 @@ for each found device:
 \item To get an automatically assigned minor number.
 \item To specify a name for the device file in {\em devtmpfs}. We
   propose to use {\tt devm\_kasprintf(\&pdev->dev, GFP\_KERNEL,
-  "serial-\%x", res->start)}. \kfunc{devm_kasprintf} allocates a
-  buffer and runs \kfunc{kasprintf} to fill its contents.
+  "serial-\%x", platform\_get\_resource(pdev, IORESOURCE\_MEM, 0)->start)}.
+  \kfunc{devm_kasprintf} allocates a buffer and runs \kfunc{kasprintf}
+  to fill its contents. \kfunc{platform_get_resource} is used to
+  retrieve the device physical address from the device tree.
+  A much simpler solution to get a unique name for the device file
+  would have been to use \code{&pdev->name}, but this would create
+  unusual names for device files (e.g. \code{48024000.serial}).
 \item To pass the \ksym{file_operations} structure that you defined.
 \item To set the \code{parent} pointer to the appropriate value.

More information about the training-materials-updates mailing list