misc_register(),注册将在/dev下自动生成设备节点,主设备号为10,从设备号一般采用动态分配方式
static struct file_operations helloworld_mic_fops = {
.owner = THIS_MODULE,
// .open = helloworld_open,
// .release = helloworld_release,
// .ioctl = helloworld_ioctl,
};
static struct miscdevice helloworld_mic_device = {
.minor = MISC_DYNAMIC_MINOR, //动态分配从设备号
.name = "helloworld_misc", //设备节点名
.fops = &helloworld_mic_fops,
};
misc_register(&helloworld_mic_device);
misc_deregister(&helloworld_mic_device);