فهرست منبع

添加sysfs power驱动接口

monkeylqd 1 ماه پیش
والد
کامیت
3934d16d83
1فایلهای تغییر یافته به همراه40 افزوده شده و 0 حذف شده
  1. 40 0
      fan.c

+ 40 - 0
fan.c

@@ -222,6 +222,38 @@ static ssize_t voltage_vcore_store(struct kobject *kobj, struct kobj_attribute *
     return count;
     return count;
 }
 }
 
 
+static ssize_t ac_power_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "ac_power_show count=%d\n", count);
+}
+
+static ssize_t ac_power_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("ac_power_store kernel rev:%s\n", buf);
+    return count;
+}
+
+static ssize_t power_flag_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "power_flag_show count=%d\n", count);
+}
+
+static ssize_t power_flag_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("power_flag_store kernel rev:%s\n", buf);
+    return count;
+}
+
 static struct kobj_attribute fan1_input =
 static struct kobj_attribute fan1_input =
     __ATTR(fan1_input, 0644, fan1_input_show, fan1_input_store);
     __ATTR(fan1_input, 0644, fan1_input_show, fan1_input_store);
 
 
@@ -249,6 +281,12 @@ static struct kobj_attribute voltage_12v =
 static struct kobj_attribute voltage_vcore =
 static struct kobj_attribute voltage_vcore =
     __ATTR(voltage_vcore, 0644, voltage_vcore_show, voltage_vcore_store);
     __ATTR(voltage_vcore, 0644, voltage_vcore_show, voltage_vcore_store);
 
 
+static struct kobj_attribute ac_power =
+    __ATTR(ac_power, 0644, ac_power_show, ac_power_store);
+
+static struct kobj_attribute power_flag =
+    __ATTR(power_flag, 0644, power_flag_show, power_flag_store);
+
 /* ==================== 属性组 ==================== */
 /* ==================== 属性组 ==================== */
 static struct attribute *fan_attrs[] = {
 static struct attribute *fan_attrs[] = {
     &fan1_input.attr,
     &fan1_input.attr,
@@ -260,6 +298,8 @@ static struct attribute *fan_attrs[] = {
     &voltage_5v.attr,
     &voltage_5v.attr,
     &voltage_12v.attr,
     &voltage_12v.attr,
     &voltage_vcore.attr,
     &voltage_vcore.attr,
+    &ac_power.attr,
+    &power_flag.attr,
     NULL,
     NULL,
 };
 };