瀏覽代碼

compatible=pwm-backlight获取compatible属性

xuxinyi 1 年之前
父節點
當前提交
0d3913bd64
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      驱动文件/5/dtsof.c

+ 11 - 1
驱动文件/5/dtsof.c

@@ -3,6 +3,7 @@
 #include <linux/of.h>
 
 struct device_node *nd; /* 设备节点 */
+struct property *comppro;
 
 static int __init helloworld_init(void) {
     pr_info("Hello world initialization!\n");
@@ -16,7 +17,16 @@ static int __init helloworld_init(void) {
         printk("my_backlight node found!\n");
     }
 
-    return 0;
+    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) {