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參數(shù),! { 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); 新版本: /******* 功能:內(nèi)核驅(qū)動(dòng)注冊(cè)完后,,用以下代碼創(chuàng)建設(shè)備文件 ******/ mydriver_class = class_create(THIS_MODULE, DEVICE_NAME); //注冊(cè)一個(gè)類,使mdev可以在"/dev/"目錄下 面建立設(shè)備節(jié)點(diǎn) //創(chuàng)建一個(gè)設(shè)備節(jié)點(diǎn),,節(jié)點(diǎn)名為DEVICE_NAME device_create(mydriver_class, NULL, devno, NULL, DEVICE_NAME); |
|