From e28a6bf75de1d098df46f46d710ebb0aefb21db7 Mon Sep 17 00:00:00 2001
From: Benedikt Spranger <b.spranger@linutronix.de>
Date: Tue, 24 Nov 2009 10:52:22 +0100
Subject: Platform device added

---
 .../module-basics/pres_module-basics_de.tex        | 197 ++++++++++++++++++++-
 1 file changed, 191 insertions(+), 6 deletions(-)

(limited to 'kernel-devel/module-basics/pres_module-basics_de.tex')

diff --git a/kernel-devel/module-basics/pres_module-basics_de.tex b/kernel-devel/module-basics/pres_module-basics_de.tex
index a62397c..533a668 100644
--- a/kernel-devel/module-basics/pres_module-basics_de.tex
+++ b/kernel-devel/module-basics/pres_module-basics_de.tex
@@ -134,22 +134,22 @@ vain_exit: done
 
 % ----- Slide Komplexere Module ------------------
 \begin{frame}
-\frametitle{Komplexere Modul}
+\frametitle{Komplexere Module}
 \pause
 \begin{itemize}
 \item Teil eines Bussystems
 \pause
 \begin{itemize}
-\item USB
-\pause
 \item PCI
 \pause
 \item Platform
 \pause
+\item USB
+\pause
 \item \dots
 \pause
 \end{itemize}
-\item Teil eines Subsystems
+\item Teil eines Subsystems\footnote{nicht Teil des Vortrages}
 \pause
 \begin{itemize}
 \item Character-Devices
@@ -182,7 +182,7 @@ vain_exit: done
 \pause
 \begin{tiny}
 \begin{lstlisting}[frame=trBL]
-static int vain_pci_init(void)
+static int __init vain_pci_init(void)
 {
         int err;
 
@@ -207,7 +207,7 @@ module_init(vain_pci_init);
 \pause
 \begin{tiny}
 \begin{lstlisting}[frame=trBL]
-static void vain_pci_exit(void)
+static void __exit vain_pci_exit(void)
 {
         |pci_unregister_driver(&vain_pci_driver);|
         printk(KERN_INFO ``vain_pci_exit: done\n'');
@@ -368,4 +368,189 @@ module_exit(vain_pci_exit);
 \end{tiny}
 \end{frame}
 
+% ----- Slide Platform Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines Platform Treiber Moduls}
+\pause
+\begin{itemize}
+\item Header
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+#include <linux/init.h>
+#include <linux/module.h>
+|#include <linux/platform_device.h>
+
+#include <asm/io.h>|
+\end{lstlisting}
+\end{tiny}
+\pause
+\item Init
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+static int __init vain_plat_init(void)
+{
+        int err;
+
+        |err = platform_driver_register(&vain_plat_driver);|
+
+        if (!err)
+                printk(KERN_INFO ``vain_plat_init: done\n'');
+        return err;
+}
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide Platform Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines Platform Treiber Moduls (fort.)}
+\pause
+\begin{itemize}
+\item Exit
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+static void __exit vain_plat_exit(void)
+{
+        |platform_driver_unregister(&vain_plat_driver);|
+        printk(KERN_INFO ``vain_plat_exit: done\n'');
+}
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide Platform Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines Platform Treiber Moduls (fort.)}
+\pause
+\begin{itemize}
+\item struct platform\_driver
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static struct platform_driver vain_plat_driver = {
+        .driver         = {
+                .name   = "vain_plat",
+                .owner  = THIS_MODULE,
+        },
+        .probe          = vain_plat_probe,
+        .remove         = __devexit_p(vain_plat_remove),
+};|
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide Platform Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines Platform Treiber Moduls (fort.)}
+\pause
+\begin{itemize}
+\item probe
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static int __devinit vain_plat_probe(struct platform_device *pdev)
+{
+        struct resource *res;
+        int err;
+
+        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+        if (unlikely(!res))
+                goto err_free;
+
+        mem = request_mem_region(res->start, resource_size(res), pdev->name);
+        if (!mem)
+                goto err_free;
+
+        info->base = ioremap(res->start, resource_size(res));
+        if (!info->base)
+                goto err_ioremap;
+
+        platform_set_drvdata(pdev, info);
+
+        return 0;|
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide Platform Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines Platform Treiber Moduls (fort.)}
+\pause
+\begin{itemize}
+\item remove
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static int __devexit vain_plat_remove(struct platform_device *pdev)
+{
+        struct vain_plat_info *info = platform_get_drvdata(pdev);
+        struct resource *res;
+
+        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+        iounmap(info->base);
+        release_mem_region(res->start, resource_size(res));
+        platform_set_drvdata(pdev, NULL);
+
+        kfree (info);
+
+        return 0;
+}|
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber Hintergrund ------------------
+\begin{frame}
+\frametitle{Platform Treiber Hintergrund}
+\includegraphics[width=7cm]{images/plat_driver.png}
+\end{frame}
+
+% ----- Slide Platform Rumpf Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Platform Rumpf Treiber}
+\begin{tiny}
+\lstinputlisting{vain_plat/vain_plat_1.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide Platform Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Platform Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_plat/vain_plat_2.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide Platform Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Platform Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_plat/vain_plat_3.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide Platform Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Platform Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_plat/vain_plat_4.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide Platform Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Platform Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_plat/vain_plat_5.c}
+\end{tiny}
+\end{frame}
+
 \end{document}
-- 
cgit v1.2.3

