Some more about implementing simple character devices.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 7 Dec 2009 05:08:01 +0000 (03:08 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 7 Dec 2009 05:08:01 +0000 (03:08 -0200)
03.char/03.char.xml

index 3c9f8cd..43a871a 100644 (file)
@@ -31,10 +31,58 @@ MKDEV
 </itemizedlist>
 </foil>
 
+<foil>
+<title>Allocating numbers</title>
+<para>
+Use <emphasis>register\_chrdev\_region</emphasis> or
+<emphasis>alloc\_chrdev\_region</emphasis> to register or allocate device
+numbers.
+</para>
+<para>
+Use <emphasis>unregister\_chrdev\_region</emphasis> to unregister it.
+</para>
+</foil>
+
+<foil>
+<title>cdev structure</title>
+<para>
+Use <emphasis>cdev\_alloc</emphasis> or <emphasis>cdev\_init</emphasis> to
+allocate or initalize a cdev structure.
+</para>
+<para>
+Use <emphasis>cdev\_add</emphasis> and <emphasis>cdev\_del</emphasis> to
+register and unregister it.
+</para>
+</foil>
+
+<foil>
+<title>Open/Release</title>
+<para>
+Implementing open and release should be very simple for many devices. They
+usually allocate data, and multiplex devices by minor number.
+</para>
+</foil>
+
 <foil>
 <title>Inode structure</title>
 <para>
-Use <emphasis>imajor</emphasis> and <emphasis>iminor</emphasis> to get the major and minor number from an inode structure.
+Use <emphasis>imajor</emphasis> and <emphasis>iminor</emphasis> to get the major
+and minor number from an inode structure.
+</para>
+</foil>
+
+<foil>
+<title>Read</title>
+<para>
+Read may write to user space less bytes than requested.
+</para>
+</foil>
+
+<foil>
+<title>Write</title>
+<para>
+Write is very similar to read. Only problem is that many applications misbehave
+when driver writes less bytes than requested.
 </para>
 </foil>