#include #include #include struct device_node *nd; /* 设备节点 */ struct property *comppro; static int __init helloworld_init(void) { pr_info("Hello world initialization!\n"); // 第一个参数设置为 NULL,从根节点开始查找 nd = of_find_node_by_path("/my_backlight"); if (nd == NULL) { printk("my_backlight node not found!\n"); return -EINVAL; } else { printk("my_backlight node found!\n"); } comppro = of_find_property(nd, "compatible", NULL); if(comppro == NULL){ ret = -EINVAL; goto fail_finish; }else{ printk("compatible=%s\r\n",(char *)comppro->value); } goto fail_finish: return ret; } static void __exit helloworld_exit(void) { pr_info("Hello world exit\n"); } module_init(helloworld_init); module_exit(helloworld_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("John Madieu "); MODULE_DESCRIPTION("Linux kernel module skeleton");