Переглянути джерело

添加Voltage sysfs驱动接口

monkeylqd 1 місяць тому
батько
коміт
91a0d21ceb
1 змінених файлів з 60 додано та 0 видалено
  1. 60 0
      fan.c

+ 60 - 0
fan.c

@@ -174,6 +174,54 @@ static ssize_t pwm2_enable_store(struct kobject *kobj, struct kobj_attribute *at
     return count;
 }
 
+static ssize_t voltage_5v_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "voltage_5v_show count=%d\n", count);
+}
+
+static ssize_t voltage_5v_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("voltage_5v_store kernel rev:%s\n", buf);
+    return count;
+}
+
+static ssize_t voltage_12v_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "voltage_12v_show count=%d\n", count);
+}
+
+static ssize_t voltage_12v_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("voltage_12v_store kernel rev:%s\n", buf);
+    return count;
+}
+
+static ssize_t voltage_vcore_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "voltage_vcore_show count=%d\n", count);
+}
+
+static ssize_t voltage_vcore_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("voltage_vcore_store kernel rev:%s\n", buf);
+    return count;
+}
+
 static struct kobj_attribute fan1_input =
     __ATTR(fan1_input, 0644, fan1_input_show, fan1_input_store);
 
@@ -192,6 +240,15 @@ static struct kobj_attribute pwm2 =
 static struct kobj_attribute pwm2_enable =
     __ATTR(pwm2_enable, 0644, pwm2_enable_show, pwm2_enable_store);
 
+static struct kobj_attribute voltage_5v =
+    __ATTR(voltage_5v, 0644, voltage_5v_show, voltage_5v_store);
+
+static struct kobj_attribute voltage_12v =
+    __ATTR(voltage_12v, 0644, voltage_12v_show, voltage_12v_store);
+
+static struct kobj_attribute voltage_vcore =
+    __ATTR(voltage_vcore, 0644, voltage_vcore_show, voltage_vcore_store);
+
 /* ==================== 属性组 ==================== */
 static struct attribute *fan_attrs[] = {
     &fan1_input.attr,
@@ -200,6 +257,9 @@ static struct attribute *fan_attrs[] = {
     &pwm1_enable.attr,
     &pwm2.attr,
     &pwm2_enable.attr,
+    &voltage_5v.attr,
+    &voltage_12v.attr,
+    &voltage_vcore.attr,
     NULL,
 };