scull代码随笔

来源:互联网 发布:如何加入网络打印机 编辑:程序博客网 时间:2024/06/08 05:03

        1. 两种函数的区别:register_chrdev_region(alloc_chrdev_region)只是向系统注册一个设备号,接着还是需要使用cdev_add把这个设备号对应的内核结构向操作系统注册。

 

struct cdev {

struct kobject kobj;

struct module *owner;

const struct file_operations *ops;  // 向系统注册时,给系统能够调用的操作指针

struct list_head list;

dev_t dev;                                    // 设备号,通过这个值,操作系统就可以把某个特定的设备号和内核的某个数据结构联系在一起

unsigned int count;

};

原创粉丝点击