mknod和register_chrdev_region()得到的设备号有什么区别?
我参看这里:
http://apps.hi.baidu.com/share/detail/33924984
这个把内存当做是字符设备驱动有个问题看不懂,
static int __init memdev_init(void) { int result; int err; int i; //申请设备号 dev_t devno = MKDEV(251, 0); if(mem_major) result= register_chrdev_region(devno, MEMDEV_NUM, "memdev");//注意静态申请的dev_t参数和动态dev_t参数的区别 else{ //静态直接传变量,动态传变量指针 result= alloc_chrdev_region(&devno, 0, MEMDEV_NUM, "memdev"); mem_major= MAJOR(devno); } if(result< 0){ printk("can'tget major devno:%d\n", mem_major); returnresult; }