根据键名解析特定属性的值相关API

编程入门 行业动态 更新时间:2024-10-26 06:34:10

根据键名解析特定<a href=https://www.elefans.com/category/jswz/34/1771415.html style=属性的值相关API"/>

根据键名解析特定属性的值相关API

mycdev.c

#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.h>struct device_node *node; //解析得到的设备树节点对象指针
struct property *pr;   //属性结构体指针
int len;
u32 a;
u32 b[2];
const char *str;
u8 c[6];
static int __init mycdev_init(void)
{int i;//解析设备树节点信息node = of_find_node_by_path("/mynode@0x12345678");if(node == NULL){printk("解析设备树节点失败\n");return -ENXIO;}printk("获取节点信息成功\n");//获取u32数值of_property_read_u32_index(node,"unit",0,&a);printk("%#x\n",a);printk("u32\n");//获取u32数组of_property_read_variable_u32_array(node,"unit",b,2,2);printk("%#x,%#x\n",b[0],b[1]);printk("u32数组\n");//获取字符串类型的值of_property_read_u8_array(node,"binarry",c,6);for(i=0;i<6;i++){printk("%#x\n",c[i]);}printk("u8\n");return 0;
}
static void __exit mycdev_exit(void)
{}
module_init(mycdev_init);
module_exit(mycdev_exit);
MODULE_LICENSE("GPL");

更多推荐

根据键名解析特定属性的值相关API

本文发布于:2023-12-03 07:37:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1652751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   键名   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!