소스 검색

添加Temperature sysfs驱动模块功能

1개의 변경된 파일45개의 추가작업 그리고 0개의 파일을 삭제
  1. 45 0
      fan.c

+ 45 - 0
fan.c

@@ -3836,6 +3836,47 @@ static ssize_t pwm2_enable_store(struct kobject *kobj, struct kobj_attribute *at
 	return count;
 }
 
+
+
+static ssize_t temp1_input_show(struct kobject *kobj, struct kobj_attribute *attr,
+                         char *buf)
+{
+	int nr = 0;
+	int index = 0;
+	struct it87_data *data = it87_update_device(dev_it87);
+
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])/1000);
+}
+static ssize_t temp2_input_show(struct kobject *kobj, struct kobj_attribute *attr,
+                         char *buf)
+{
+	int nr = 1;
+	int index = 0;
+	struct it87_data *data = it87_update_device(dev_it87);
+
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])/1000);
+}
+
+
+
+static ssize_t temp1_input_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    return -EINVAL;
+}
+
+static ssize_t temp2_input_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    return -EINVAL;
+}
+
+static struct kobj_attribute temp1_input =
+    __ATTR(temp1_input, 0644, temp1_input_show, temp1_input_store);
+
+static struct kobj_attribute temp2_input =
+    __ATTR(temp2_input, 0644, temp2_input_show, temp2_input_store);
+
 static struct kobj_attribute fan1_input =
     __ATTR(fan1_input, 0644, fan1_input_show, fan1_input_store);
 
@@ -3854,6 +3895,8 @@ static struct kobj_attribute pwm2 =
 static struct kobj_attribute pwm2_enable =
     __ATTR(pwm2_enable, 0644, pwm2_enable_show, pwm2_enable_store);
 
+
+
 /* ==================== 属性组 ==================== */
 static struct attribute *fan_attrs[] = {
     &fan1_input.attr,
@@ -3862,6 +3905,8 @@ static struct attribute *fan_attrs[] = {
     &pwm1_enable.attr,
     &pwm2.attr,
     &pwm2_enable.attr,
+    &temp1_input.attr,
+    &temp2_input.attr,
     NULL,
 };