当前位置:网站首页>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;
}
边栏推荐
- Chapter 4 of getting started with MySQL: data types stored in data tables
- Bigder: how to deal with the bugs found in the 32/100 test if they are not bugs
- [shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
- 关于Unity屏幕相关Screen的练习题目,Unity内部环绕某点做运动
- Seckill system design
- 百数不断创新,打造自由的低代码办公工具
- 【雅思阅读】王希伟阅读P2(阅读填空)
- What are the projects of metauniverse and what are the companies of metauniverse
- redis21道经典面试题,极限拉扯面试官
- [shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a
猜你喜欢

Monitor container runtime tool Falco

百数不断创新,打造自由的低代码办公工具

Should you study kubernetes?

setInterval定时器在ie不生效原因之一:回调的是箭头函数

Basic use of shell script

Talk with the interviewer about the pit of MySQL sorting (including: duplicate data problem in order by limit page)
![[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)](/img/f7/a8eb8e40b9ea25021751d7150936ac.jpg)
[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)

Custom throttling function six steps to deal with complex requirements

Which websites can I search for references when writing a thesis?

教育学大佬是怎么找外文参考文献的?
随机推荐
The most painful programming problem in 2021, adventure of code 2021 Day24
程序分析与优化 - 9 附录 XLA的缓冲区指派
来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能
Xcode real machine debugging
Slf4j + logback logging framework
布隆过滤器
Andorid 获取系统标题栏高度
What are the projects of metauniverse and what are the companies of metauniverse
Free we media essential tools sharing
Andorid gets the system title bar height
Nc50528 sliding window
国外的论文在那找?
关于Unity屏幕相关Screen的练习题目,Unity内部环绕某点做运动
How do educators find foreign language references?
[Chongqing Guangdong education] audio visual language reference materials of Xinyang Normal University
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
Form form instantiation
Multiprocess programming (V): semaphores
请问大家在什么网站上能查到英文文献?
多进程编程(五):信号量