没有指定设备号
int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name)
指定了设备号
int register_chrdev_region(dev_t from, unsigned count, const char *name)
释放设备号
void unregister_chrdev_region(dev_t from, unsigned count)
———————————————
字符设备结构
cdev
cdev 中有两个重要的成员变量: ops 和 dev,这两个就是字符设备文件操作函数集合
file_operations 以及设备号 dev_t。编写字符设备驱动之前需要定义一个 cdev 结构体变量,这个
变量就表示一个字符设备,
定义好 cdev 变量以后就要使用 cdev_init 函数对其进行初始化, cdev_init 函数原型如下:
void cdev_init(struct cdev *cdev, const struct file_operations *fops)