当前位置:网站首页>of_ find_ compatible_ Node find all nodes
of_ find_ compatible_ Node find all nodes
2022-06-13 10:36:00 【Giant octopus】
The main points of :
(1) First call of_find_compatible_node When , The first parameter is zero NULL
(2) Follow up page n Secondary call of_find_compatible_node, The first parameter is the n-1 Secondary call of_find_compatible_node The return value of
(3)of_find_compatible_node The return value of node, After use Must call of_find_compatible_node or of_node_put release
#include <linux/of.h>
#include <linux/of_address.h> // of_address_to_resource
#include <linux/of_irq.h> // irq_of_parse_and_map
#include <linux/module.h>
static int __init test_init(void)
{
int ret;
struct device_node *node;
struct resource res;
unsigned int irq = 0;
// Loop through all specified in the device tree compatible The node of
// node Must be called after use of_find_compatible_node or of_node_put release
node = NULL;
while ((node = of_find_compatible_node(node, NULL, "fsl,imx6ul-gpt")) != NULL)
{
ret = of_address_to_resource(node, 0, &res);
if (ret == 0)
{
pr_err("name=%s, full_name=%s, start=0x%08x\n", node->name, node->full_name, res.start);
if (res.start == 0x020e8000)
{
// Already found gpt2 node
irq = irq_of_parse_and_map(node, 0); // analysis interrupts attribute , obtain linux Interrupt number
pr_err("found gpt2 node: irq=%d\n", irq);
of_node_put(node); // The release of the node
break;
}
}
else
pr_err("name=%s, full_name=%s\n", node->name, node->full_name);
}
if (irq == 0)
{
// Can't find gpt2 node , Or parsing gpt2 Node interrupts Property failed
pr_err("no IRQ found\n");
return -ENODEV;
}
return 0;
}
static void __exit test_exit(void)
{
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("Oct1158");
MODULE_LICENSE("GPL");
Program run results :
[email protected]:~/learn_drivers/dts_myboard2/gpiospi_test$ sudo insmod search_nodes.ko
[ 1265.669315] name=gpt, full_name=/soc/[email protected]/[email protected], start=0x02098000
[ 1265.677645] name=gpt, full_name=/soc/[email protected]/[email protected], start=0x020e8000
[ 1265.687307] found gpt2 node: irq=213
边栏推荐
- Talk about the bottom playing method of C # method overloading
- string类对象的修改操作
- QTcpServer. QTcpSocket. QUdpSocket之间的区别
- 格林纳达代表团团长孙宇晨出席WTO MC12 强调发展数字经济
- Some experience in database table structure design
- Install Kubernetes 1.24
- d求值两次map
- SSM整合初步 所得细节
- 在 Kubernetes 集群上部署 VSCode
- Record several interesting XSS vulnerability discoveries
猜你喜欢
On the exploitation of a horizontal ultra vires vulnerability
[image denoising] image denoising based on MATLAB Gaussian + mean + median + bilateral filtering [including Matlab source code 1872]
go-zero微服务实战系列(三、API定义和表结构设计)
Full stack development practice | integrated development of SSM framework
电赛校赛经验-程控风力摆
基于单片机的简易电子钟设计
Docker deployment MySQL
Node red series (25): integrate Gaode map and realize 3D map and track playback
Win7 cannot be remote desktop problem
vivo大规模 Kubernetes 集群自动化运维实践
随机推荐
Cynthia project defect management system
【ELM分类】基于粒子群优化卷积神经网络CNN结合极限学习机ELM实现数据分类附matlab代码
Introduction to binary tree
Test cases that testers must master
go-zero微服务实战系列(三、API定义和表结构设计)
Blue Bridge Cup group 2021a - two way sorting
Review of last week's hot spots (6.6-6.12)
文件夹数据同步工具Sync Folders Pro
Node-RED系列(二五):集成高德地图并实现3d地图和轨迹回放
Implementation of fruit mall wholesale platform based on SSM
Similarities and differences between decoration mode and agency mode
flutter简单优秀的开源dialog使用free_dialog
为发泄对上司不满,百度95后程序员删库被判9个月
Node red series (25): integrate Gaode map and realize 3D map and track playback
Sunyuchen, head of Grenada delegation, attended the WTO MC12 and emphasized the development of digital economy
Brief introduction to memory structure of virtual machine
Wait for someone with "source" | openharmony growth plan student challenge registration to start
Introduction to knowledge map
计算循环冗余码--摘录
matlab轮毂电机分析模糊pid控制垂向振动分析