属性的值相关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
发布评论