当前位置: 技术问答>linux和unix
内核模块加载成功,但设备号申请不到
来源: 互联网 发布时间:2017-03-25
本文导语: linux2.6内核,驱动模块加载成功了,但是设备号确申请不到.. 就是用cat /proc/devices 查看后没有自己预设要注册的主设备号... | if (major) { devid = MKDEV(major, 0); ret = register_chrdev_region(...
linux2.6内核,驱动模块加载成功了,但是设备号确申请不到.. 就是用cat /proc/devices 查看后没有自己预设要注册的主设备号...
|
if (major) {
devid = MKDEV(major, 0);
ret = register_chrdev_region(devid, 1, SST_MODULE_NAME);
} else {
ret = alloc_chrdev_region(&devid, 0, 1, SST_MODULE_NAME);
major = MAJOR(devid);
}
devid = MKDEV(major, 0);
ret = register_chrdev_region(devid, 1, SST_MODULE_NAME);
} else {
ret = alloc_chrdev_region(&devid, 0, 1, SST_MODULE_NAME);
major = MAJOR(devid);
}
|
顶 1楼
|
if (major) {
devid = MKDEV(major, 0);
ret = register_chrdev_region(devid, 1, SST_MODULE_NAME);
} else {
ret = alloc_chrdev_region(&devid, 0, 1, SST_MODULE_NAME);
major = MAJOR(devid);
}
用printk加在上面,看结果罗。顶一楼二楼。
devid = MKDEV(major, 0);
ret = register_chrdev_region(devid, 1, SST_MODULE_NAME);
} else {
ret = alloc_chrdev_region(&devid, 0, 1, SST_MODULE_NAME);
major = MAJOR(devid);
}
用printk加在上面,看结果罗。顶一楼二楼。