基本思路:
1.module_init(初始化函数)
2.module_exit(退出时的函数)
3.初始化函数要做的基本工作:
   request_irq()//为设备申请中断
   register_chrdev()//注册字符型设备的操作
   操作类型存于file_operations结构体中
4.具体实现file_operations结构体中涉及的操作,基本的有open,read,write,release,ctl...
ps:
module_init,module_exit两个宏定义在<linux/init.h>中,
file_operations结构体定义于<linux/fs.h>中,
register_chrdev()函数声明在<linux/fs.h>中,定义在<linux/fs/dervices.c>中,
request_irq()函数声明在<linux/sched.h>中,

//AD驱动模块

//Makefile
模块驱动相关TARGET = helloworld
模块驱动相关KDIR 
= /usr/src/linux
模块驱动相关PWD 
= $(shell pwd)
模块驱动相关obj
-+= $(TARGET).o
模块驱动相关
default:
模块驱动相关 make 
-C $(KDIR) M=$(PWD) modules 

相关文章: