当前位置:网站首页>字符设备注册常用的两种方法和步骤
字符设备注册常用的两种方法和步骤
2022-07-02 23:09:00 【要不要买菜!】

static int __init RK_irq_init(void)
{
/* 1、构建设备号 */
if (RK_irq.major) {
RK_irq.devid = MKDEV(RK_irq.major, 0);
register_chrdev_region(RK_irq.devid, RK_IRQ_CNT, RK_IRQ_NAME);
} else {
alloc_chrdev_region(&RK_irq.devid, 0, RK_IRQ_CNT, RK_IRQ_NAME);
RK_irq.major = MAJOR(RK_irq.devid);
RK_irq.minor = MINOR(RK_irq.devid);
}
/* 2、注册字符设备 */
cdev_init(&RK_irq.cdev, &RK_irq_fops);
cdev_add(&RK_irq.cdev, RK_irq.devid, RK_IRQ_CNT);
/* 3、创建类 */
RK_irq.class = class_create(THIS_MODULE, RK_IRQ_NAME);
if (IS_ERR(RK_irq.class)) {
return PTR_ERR(RK_irq.class);
}
/* 4、创建设备 */
RK_irq.device = device_create(RK_irq.class, NULL, RK_irq.devid, NULL, RK_IRQ_NAME);
if (IS_ERR(RK_irq.device)) {
return PTR_ERR(RK_irq.device);
}
/* 5、始化按键 */
atomic_set(&RK_irq.keyvalue, INVAKEY);
atomic_set(&RK_irq.releasekey, 0);
keyio_init();
return 0;
}
边栏推荐
- 论文的设计方案咋写?
- sysdig分析容器系统调用
- 哪些软件可以整篇翻译英文论文?
- [shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
- 多进程编程(二):管道
- Is the multitasking loss in pytoch added up or backward separately?
- Interpretation of new plug-ins | how to enhance authentication capability with forward auth
- Architecture: load balancing
- Feature Engineering: summary of common feature transformation methods
- Go custom sort
猜你喜欢
![[shutter] shutter open source project reference](/img/3f/b1d4edd8f8e8fd8e6b39548448270d.jpg)
[shutter] shutter open source project reference

TypeError: Cannot read properties of undefined (reading ***)

Is the multitasking loss in pytoch added up or backward separately?

开源了 | 文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开

Sysdig analysis container system call
![Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation](/img/4a/ab732c41ea8a939fa0983fec475622.png)
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation

sysdig分析容器系统调用

Bigder: how to deal with the bugs found in the 32/100 test if they are not bugs

监控容器运行时工具Falco
![洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表](/img/4a/ab732c41ea8a939fa0983fec475622.png)
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
随机推荐
数组常用操作方法整理(包含es6)及详细使用
zhvoice
Pytorch 20 realizes corrosion expansion based on pytorch
可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
What are the recommended thesis translation software?
Interpretation of new plug-ins | how to enhance authentication capability with forward auth
[reading notes] phased summary of writing reading notes
【单片机项目实训】八路抢答器
NC24840 [USACO 2009 Mar S]Look Up
Multi process programming (III): message queue
redis21道经典面试题,极限拉扯面试官
67 page overall planning and construction plan for a new smart city (download attached)
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
Where can I find foreign papers?
JS interviewer wants to know how much you understand call, apply, bind no regrets series
经济学外文文献在哪查?
大学生课堂作业2000~3000字的小论文,标准格式是什么?
95 pages of smart education solutions 2022
Nc20806 District interval
[target detection] r-cnn, fast r-cnn, fast r-cnn learning