Explorar el Código

compatible=pwm-backlight获取compatible属性

xuxinyi hace 1 año
padre
commit
0d3913bd64
Se han modificado 1 ficheros con 11 adiciones y 1 borrados
  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) {