当前位置:网站首页>主设备号和次设备号均为0
主设备号和次设备号均为0
2022-07-06 21:42:00 【火红色祥云】
如题
驱动模块装载后,打印的字符设备的主设备号和次设备号均为0
原因
代码问题
问题代码
st_ap3216cDev.dev_id = alloc_chrdev_region(&st_ap3216cDev.dev_id,0,1,NAME);
st_ap3216cDev.major = MAJOR(st_ap3216cDev.dev_id);
st_ap3216cDev.minor = MINOR(st_ap3216cDev.dev_id);
printk("Major:%d minor:%d\n",st_ap3216cDev.major,st_ap3216cDev.minor);
看着好像没什么问题
其实代码应该为:
alloc_chrdev_region(&st_ap3216cDev.dev_id,0,1,NAME);
st_ap3216cDev.major = MAJOR(st_ap3216cDev.dev_id);
st_ap3216cDev.minor = MINOR(st_ap3216cDev.dev_id);
printk("Major:%d minor:%d\n",st_ap3216cDev.major,st_ap3216cDev.minor);
- 设备号申请成功后,返回值为0,把返回值有赋值为设备号变量,所以打印的注射号和次设备号为0。裂开。。。
边栏推荐
- Implementation of binary search tree
- Hongmi K40S root gameplay notes
- ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
- Redis source code learning (30), dictionary learning, dict.h
- 使用Thread类和Runnable接口实现多线程的区别
- Analysis on urban transportation ideas of 2022 Zhongqing cup C
- VIM - own active button indent this command "suggestions collection"
- Use facet to record operation log
- Kbone与小程序跨端开发的一些思考
- cuda编程
猜你喜欢
2022 electrician cup question B analysis of emergency materials distribution under 5g network environment
科兴与香港大学临床试验中心研究团队和香港港怡医院合作,在中国香港启动奥密克戎特异性灭活疫苗加强剂临床试验
How to detect whether the MySQL code runs deadlock +binlog view
史上最全MongoDB之Mongo Shell使用
The most complete security certification of mongodb in history
[record of question brushing] 2 Add two numbers
Implementation of map and set
ABAP 动态内表分组循环
idea gradle lombok 报错集锦
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
随机推荐
Adaptive non European advertising retrieval system amcad
Redis source code learning (30), dictionary learning, dict.h
Use facet to record operation log
红米k40s root玩机笔记
SQL injection -day15
2022中青杯C题城市交通思路分析
vim —- 自己主动的按钮indent该命令「建议收藏」
【OA】Excel 文档生成器: Openpyxl 模块
PHP 实现根据概率抽奖
The most complete deployment of mongodb in history
【写给初发论文的人】撰写综述性科技论文常见问题
见到小叶栀子
easyui出口excel无法下载框弹出的办法来解决
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
Golang compresses and decompresses zip files
golang 根据生日计算星座和属相
Quick completion guide of manipulator (10): accessible workspace
Using thread class and runnable interface to realize the difference between multithreading
map和set的实现
ggplot 分面的细节调整汇总