LDD 5 How to write char dev driver with file_operations - limingth/LASO GitHub Wiki

LDD 5 How to write char dev driver with file_operations

1. init & exit

#include <linux/module.h>
#include <asm/io.h>
--
ioremap()
module_init()
module_exit()

2. open & release

#include <linux/fs.h>
--
file_operations led_fops = {
    .owner = THIS_MODULE,
    .open = 
    .release = 
    .write = 
    .read = 
    .ioctl = 
}
MAJOR()
MINOR()
register_chrdev()
unregister_chrdev()

3. write & read

copy_from_user()
copy_to_user()

4. ioctl

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
---
⚠️ **GitHub.com Fallback** ⚠️