当前位置:网站首页>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;
}
边栏推荐
- Multiprocess programming (V): semaphores
- 英文论文有具体的格式吗?
- [shutter] open the third-party shutter project
- 在线预览Word文档
- [Chongqing Guangdong education] audio visual language reference materials of Xinyang Normal University
- NC24325 [USACO 2012 Mar S]Flowerpot
- Xcode real machine debugging
- Form form instantiation
- Seckill system design
- collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
猜你喜欢
详解用OpenCV的轮廓检测函数findContours()得到的轮廓拓扑结构(hiararchy)矩阵的意义、以及怎样用轮廓拓扑结构矩阵绘制轮廓拓扑结构图
TypeError: Cannot read properties of undefined (reading ***)
Automated defect analysis in electron microscopic images-论文阅读笔记
来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能
Where can I find the English literature of the thesis (except HowNet)?
字符设备注册常用的两种方法和步骤
Multiprocess programming (I): basic concepts
Digital collection trading website domestic digital collection trading platform
Markdown tutorial
Architecture: load balancing
随机推荐
Shell脚本基本使用
【单片机项目实训】八路抢答器
有哪些比较推荐的论文翻译软件?
LeedCode1480.一维数组的动态和
为什么网站打开速度慢?
Confluence的PDF导出中文文档异常显示问题解决
Introduction of UART, RS232, RS485, I2C and SPI
Additional: token; (don't read until you finish writing...)
redis21道经典面试题,极限拉扯面试官
Cmake basic use
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
NC17059 队列Q
Preview word documents online
简单聊聊运维监控的其他用途
字符设备注册常用的两种方法和步骤
[shutter] open the third-party shutter project
Nc20806 District interval
Multiprocess programming (I): basic concepts
Should you study kubernetes?
How do educators find foreign language references?