[bootlin/training-materials updates] master: kernel: serial: Update the way we create the misc device name (bdbd870d)

Miquel Raynal miquel.raynal at bootlin.com
Fri May 7 12:01:45 CEST 2021

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


commit bdbd870d1fe9b4454945d5ee6e5365233b283d30
Author: Miquel Raynal <miquel.raynal at bootlin.com>
Date:   Fri May 7 11:56:15 2021 +0200

    kernel: serial: Update the way we create the misc device name
    This has also been updated in the labs.
    Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>


 labs/kernel-serial-output/kernel-serial-output.tex | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/labs/kernel-serial-output/kernel-serial-output.tex b/labs/kernel-serial-output/kernel-serial-output.tex
index dbe7e62c..354a10bb 100644
--- a/labs/kernel-serial-output/kernel-serial-output.tex
+++ b/labs/kernel-serial-output/kernel-serial-output.tex
@@ -63,7 +63,15 @@ 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
-  "serial-\%llx", platform\_get\_resource(pdev, IORESOURCE\_MEM, 0)->start)}.
+  propose to use:
+  \begin{verbatim}
+struct resource *res;
+res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+/* Error handling */
+devm_kasprintf(&pdev->dev, GFP_KERNEL, "serial-\%llx", res->start);
+  \end{verbatim}
   \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.

More information about the training-materials-updates mailing list