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;
};