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