Polish char device chapter a little.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 16 May 2010 19:20:37 +0000 (16:20 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 16 May 2010 19:20:37 +0000 (16:20 -0300)
04char/chrdev

index e680075..a48e677 100644 (file)
@@ -1,3 +1,6 @@
+%Character Devices
+%Thadeu Cascardo
+
 # Introduction
 
 Devices in POSIX Systems are files in /dev directory. As with any files
@@ -28,21 +31,6 @@ Linux devices may be of different types, including character devices,
 block devices or network devices. Both character and block devices have
 identifying numbers, a major and a minor number.
 
-# Character devices allocation
-
-In Linux, major and minor numbers have to be requested or allocated. The
-calls to do that for character devices are:
-
-
-* int register\\_chrdev\\_region (dev\\_t first, unsigned int count, char
-*name);
-* int alloc\\_chrdev\\_region (dev\\_t *dev, unsigned int firstminor,
-unsigned int count, char *name);
-* void unregister\\_chrdev\\_region (dev\\_t dev, unsigned int count);
-
-
-
-
 # VFS
 
 # Introduction
@@ -63,13 +51,18 @@ When handling with special files (character and block device nodes), procfs
 files and others, we'll use some common structures. These include the
 *struct file\\_operations*, *struct file* and *struct inode*.
 
+Do not forget to include linux/fs.h.
+
 # File Operations
 
+* owner
 * open
 * release
+* flush
 * read
 * write
 * ioctl
+* unlocked_ioctl
 * llseek
 * poll
 * mmap
@@ -88,9 +81,6 @@ files and others, we'll use some common structures. These include the
 The inode is a representation of the file as in its filesystem, including its
 major/minor numbers and pointers to the corresponding device representation.
 
-
-
-
 # Character Devices
 
 # Device Number Macros
@@ -98,16 +88,21 @@ major/minor numbers and pointers to the corresponding device representation.
 Nowadays, major number is 12 bits and minor number is 20 bits. This may change
 in the future, so macros should be used.
 
+* include linux/kdev_t.h
 * MAJOR
 * MINOR
 * MKDEV
 
-# Allocating numbers
+# Character devices allocation
 
-Use *register\\_chrdev\\_region* or *alloc\\_chrdev\\_region* to register or
-allocate device numbers.
+In Linux, major and minor numbers have to be requested or allocated. The
+calls to do that for character devices are:
 
-Use *unregister\\_chrdev\\_region* to unregister it.
+* int register\\_chrdev\\_region (dev\\_t first, unsigned int count, char
+*name);
+* int alloc\\_chrdev\\_region (dev\\_t *dev, unsigned int firstminor,
+unsigned int count, char *name);
+* void unregister\\_chrdev\\_region (dev\\_t dev, unsigned int count);
 
 # cdev structure