当前位置:网站首页>Two common methods and steps of character device registration
Two common methods and steps of character device registration
2022-07-03 00:28:00 【Do you want to buy vegetables!】

static int __init RK_irq_init(void)
{
/* 1、 Build device number */
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、 Register character device */
cdev_init(&RK_irq.cdev, &RK_irq_fops);
cdev_add(&RK_irq.cdev, RK_irq.devid, RK_IRQ_CNT);
/* 3、 Create a class */
RK_irq.class = class_create(THIS_MODULE, RK_IRQ_NAME);
if (IS_ERR(RK_irq.class)) {
return PTR_ERR(RK_irq.class);
}
/* 4、 Create device */
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、 Start button */
atomic_set(&RK_irq.keyvalue, INVAKEY);
atomic_set(&RK_irq.releasekey, 0);
keyio_init();
return 0;
}
边栏推荐
- Should you study kubernetes?
- 程序分析与优化 - 9 附录 XLA的缓冲区指派
- Pytorch里面多任务Loss是加起来还是分别backward?
- TypeError: Cannot read properties of undefined (reading ***)
- 数组常用操作方法整理(包含es6)及详细使用
- [shutter] open the third-party shutter project
- Andorid 获取系统标题栏高度
- [reading notes] phased summary of writing reading notes
- What website can you find English literature on?
- 秒杀系统设计
猜你喜欢

Chapter 3 of getting started with MySQL: database creation and operation

有哪些比较推荐的论文翻译软件?

Mutual exclusion and synchronization of threads
![[target detection] r-cnn, fast r-cnn, fast r-cnn learning](/img/f0/df285f01ffadff62eb3dcb92f2e04f.jpg)
[target detection] r-cnn, fast r-cnn, fast r-cnn learning

Redis21 classic interview questions, extreme pull interviewer

pod生命周期详解

Custom throttling function six steps to deal with complex requirements

Where can I find the English literature of the thesis (except HowNet)?

ftrace工具的介绍及使用

【单片机项目实训】八路抢答器
随机推荐
Thinkadmin V6 arbitrary file read vulnerability (cve-2020-25540)
Nc20806 District interval
Improvement of RTP receiving and sending PS stream tool (II)
Architecture: load balancing
form表单实例化
How to write the design scheme of the thesis?
Mutual exclusion and synchronization of threads
NC50965 Largest Rectangle in a Histogram
Pageoffice - bug modification journey
多进程编程(二):管道
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
秒杀系统设计
Andorid 获取系统标题栏高度
v8
Blue decides red - burst CS teamserver password
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
Maya fishing house modeling
写论文可以去哪些网站搜索参考文献?
布隆过滤器
MySQL advanced learning notes (III)