Linux字符设备动态申请设备号
alloc_chrdev_region是一个函数语句,头文件是<linux/fs.h>,可以动态分配设备编号。int alloc_chrdev_region(dev_t *dev,unsigned int -firstminor,unsigned int -count,char *name); dev_t *dev:用于返回的设备号参数 unsigned int -firstminor:默认为0 unsigned int -count:请求连续设备号的个数 char *name:待注册的设备名称
//////////////////////////////////////////////////////////////////////// dev_t dev = 0; ret = alloc_chrdev_region(&dev, 0, 1,DEVICE_NAME); if(ret<0) { printk(KERN_ERR "register_chrdev_region error\r\n"); goto alloc_err; } ///////////////////////////////////////////////////////////////////////
相关推荐
tianhuak 2020-11-24
86276537 2020-11-19
大牛牛 2020-10-30
flycappuccino 2020-09-27
卢从利 2020-10-10
无忧老猪 2020-10-09
学峰的学习笔记 2020-10-05
85216033 2020-09-16
兄dei努力赚钱吧 2020-09-06
89334799 2020-08-12
ruanhongbiao 2020-08-16
邓博学习笔记 2020-08-03
ningningmingming 2020-07-28
zhongzhiwei 2020-07-27
Jiajinjin 2020-07-27
manimnchn 2020-07-26
xiyoukeke 2020-07-19
ooouuuooouuu 2020-07-19
Proudoffaith 2020-07-18