1.ioctl 与 unlocked_ioctl / int 与long 旧版本: static const struct file_operations globalmem_fops= int globalmem_ioctl(struct inode* inode,struct file* filp, unsigned int cmd,unsigned long arg) { switch (cmd) { case:XXX: ... …… } } 新版本: static const struct file_operations globalmem_fops= long globalmem_ioctl(struct file* filp, unsigned int cmd,unsigned long arg)//没有inode参数! { switch (cmd) { case:XXX: ... …… } } 2.class_create/device_create 与 devfs_mk_cdev 旧版本:devfs_mk_cdev(MKDEV(LED_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,DEVICE_NAME); 新版本: /******* 功能:内核驱动注册完后,用以下代码创建设备文件 ******/ mydriver_class = class_create(THIS_MODULE, DEVICE_NAME); //注册一个类,使mdev可以在"/dev/"目录下 面建立设备节点 //创建一个设备节点,节点名为DEVICE_NAME device_create(mydriver_class, NULL, devno, NULL, DEVICE_NAME); |
|
来自: huihaoking > 《linux模块驱动》