kernel_module: move character device example doc to README

This commit is contained in:
Ciro Santilli
2018-06-29 07:25:32 +01:00
parent 20b9961233
commit 7f3671894f
6 changed files with 80 additions and 32 deletions

View File

@@ -20,8 +20,6 @@
... link:dep2.c[]
. Pseudo filesystems
.. link:anonymous_inode.c[]
.. link:character_device.c[]
.. link:character_device_create.c[]
.. link:debugfs.c[]
.. link:fops.c[]
.. link:ioctl.c[]

View File

@@ -1,24 +1,3 @@
/*
Allows us to create device files with given file operations with mknod c X.
Usage:
/character_device.sh
The major number determines which module owns the device file.
minor is to differentiate between multiple instances of the device,
e.g. two NVIDIA GPUs using the same kernel module.
We ask the kernel to automatically allocate a major number for us to avoid
conlicts with other devices.
Then we need to check /proc/devices to find out the assigned number,
and use that for the mknod.
- https://unix.stackexchange.com/questions/37829/understanding-character-device-or-character-special-files/371758#371758
*/
#include <linux/fs.h> /* register_chrdev, unregister_chrdev */
#include <linux/module.h>
#include <linux/seq_file.h> /* seq_read, seq_lseek, single_release */

View File

@@ -1,9 +1,3 @@
/*
Automatically create the device under /dev on insmod, and remove on rmmod.
https://stackoverflow.com/questions/5970595/how-to-create-a-device-node-from-the-init-module-code-of-a-linux-kernel-module/45531867#45531867
*/
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/fs.h> /* register_chrdev, unregister_chrdev */