mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
kernel_module: move character device example doc to README
This commit is contained in:
@@ -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[]
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user