ソースを参照

添加Sysfs entry - temperature驱动模块接口

monkeylqd 1 ヶ月 前
コミット
b8d93aa632
1 ファイル変更40 行追加0 行削除
  1. 40 0
      fan.c

+ 40 - 0
fan.c

@@ -254,6 +254,38 @@ static ssize_t power_flag_store(struct kobject *kobj, struct kobj_attribute *att
     return count;
 }
 
+static ssize_t temp1_input_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "temp1_input_show count=%d\n", count);
+}
+
+static ssize_t temp1_input_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("temp1_input_store kernel rev:%s\n", buf);
+    return count;
+}
+
+static ssize_t temp2_input_show(struct kobject *kobj, struct kobj_attribute *attr,
+                                char *buf)
+{
+    static int count = 0;
+    count++;
+
+    return sprintf(buf, "temp2_input_show count=%d\n", count);
+}
+
+static ssize_t temp2_input_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    printk("temp2_input_store kernel rev:%s\n", buf);
+    return count;
+}
+
 static struct kobj_attribute fan1_input =
     __ATTR(fan1_input, 0644, fan1_input_show, fan1_input_store);
 
@@ -287,6 +319,12 @@ static struct kobj_attribute ac_power =
 static struct kobj_attribute power_flag =
     __ATTR(power_flag, 0644, power_flag_show, power_flag_store);
 
+static struct kobj_attribute temp1_input =
+    __ATTR(temp1_input, 0444, temp1_input_show, temp1_input_store);
+
+static struct kobj_attribute temp2_input =
+    __ATTR(temp2_input, 0444, temp2_input_show, temp2_input_store);
+
 /* ==================== 属性组 ==================== */
 static struct attribute *fan_attrs[] = {
     &fan1_input.attr,
@@ -300,6 +338,8 @@ static struct attribute *fan_attrs[] = {
     &voltage_vcore.attr,
     &ac_power.attr,
     &power_flag.attr,
+    &temp1_input.attr,
+    &temp2_input.attr,
     NULL,
 };