1.字符设备驱动
module_init(xxx_init); module_exit(xxx_exit); | //注册模块加载函数 //注册模块卸载函数 |
加载模块使用
insmod xxx.ko或modprobe xxx.ko
卸载模块使用
resmod xxx.ko或modprobe -r xxx.ko
推荐使用modprobe 和 resmod
字符设备注册和注销
static inline int register_chrdev(unsigned int major, const char *name,
const struct file_operations *fops)
static inline void unregister_chrdev(unsigned int major, const char *name)
设备的具体操作函数
编写了四个函数: chrtest_open、 chrtest_read、 chrtest_write和 chrtest_release
添加LICENSE和作者信息
MODULE_LICENSE() MODULE_AUTHOR() | //添加模块 LICENSE 信息 //添加模块作者信息 |
设备号分配