Skip to content

Commit

Permalink
kernel: serial: Update the way we create the misc device name
Browse files Browse the repository at this point in the history
This has also been updated in the labs.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
  • Loading branch information
miquelraynal authored and tpetazzoni committed Oct 29, 2021
1 parent a4f88e3 commit 5ca9ec5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion labs/kernel-serial-output/kernel-serial-output.tex
Expand Up @@ -63,7 +63,15 @@ \section{Misc driver registration}
\begin{itemize}
\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.
Expand Down

0 comments on commit 5ca9ec5

Please sign in to comment.