linux字元裝置驅動程式框架 老方法

2021-06-22 00:25:23 字數 1639 閱讀 6005

#include #include #include #include #include #include #include #include #include #include #include #include #define***_device_count1

/*自動建立裝置節點類*/

static struct class ****_dev_class;

static struct class_device ****_dev_class_dev;

/**/

static int ***_dev_open(struct inode *inode, struct file *filp)

static int ***_dev_close(struct inode *inode, struct file *filp)

static int ***_dev_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)

static int ***_dev_read(struct file *file, const char __user *buf, size_t count, loff_t ppos)

static int ***_dev_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)

/****裝置操作函式結構體

*/struct file_operations ***_fops = ;

/****裝置驅動模組的註冊和解除安裝

*/int ***_major = 0;

static int __init initialization_***_dev(void)

else

printk("after register *** major = %d\n", ***_major);

/* 自動生成裝置節點 */

***_dev_class = class_create(this_module, "***_dev");

***_dev_class_dev = class_device_create(***_dev_class, null, mkdev(***_major, 0), null, "***");

/* 模組初始化成功必須返回0 */

printk("module register ok.\n");

return 0;

}static void __exit cleanup_***_dev(void)

/*模組註冊與解除安裝

*/module_init(initialization_***_dev);

module_exit(cleanup_***_dev);

/*模組傳參:insmod char_driver_frame_old.ko ***_major=***

*/module_param(***_major, int, s_irugo);

/*模組的相關宣告

*/module_author("lhbo");

module_description("gpio driver for ***");

module_license("gpl");

linux字元裝置驅動程式框架

include include include include include include include include include include include include define device count1 字元裝置結構體 struct dev struct dev dev...

linux裝置驅動程式 字元裝置驅動程式

先留個 有一起學習驅動程式的加qq295699450 字元裝置驅動 這篇比較惱火。載入成功,但是讀不出來資料,有知道怎麼回事的,留個言,一起討論下 資料結構 struct scull mem struct scull dev dev 整個驅動程式 如下 include include include...

Linux裝置驅動程式 字元裝置驅動程式

1.檢視主裝置號,次裝置號 進入 dev目錄執行ls l,第四,五列分別為主次裝置號,10,180,1,5,這些是主裝置號,而60,63這些就是次裝置號 130 shell android dev ls l crw rw r system radio 10,60 1969 12 31 21 00 a...