⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f71805f.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
	mutex_lock(&data->update_lock);	data->auto_points[pwmnr].fan[apnr] = fan_to_reg(val);	f71805f_write16(data, F71805F_REG_PWM_AUTO_POINT_FAN(pwmnr, apnr),		        data->auto_points[pwmnr].fan[apnr]);	mutex_unlock(&data->update_lock);	return count;}static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,			 char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int nr = attr->index;	return sprintf(buf, "%ld\n", temp_from_reg(data->temp[nr]));}static ssize_t show_temp_max(struct device *dev, struct device_attribute			     *devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int nr = attr->index;	return sprintf(buf, "%ld\n", temp_from_reg(data->temp_high[nr]));}static ssize_t show_temp_hyst(struct device *dev, struct device_attribute			      *devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int nr = attr->index;	return sprintf(buf, "%ld\n", temp_from_reg(data->temp_hyst[nr]));}static ssize_t show_temp_type(struct device *dev, struct device_attribute			      *devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int nr = attr->index;	/* 3 is diode, 4 is thermistor */	return sprintf(buf, "%u\n", (data->temp_mode & (1 << nr)) ? 3 : 4);}static ssize_t set_temp_max(struct device *dev, struct device_attribute			    *devattr, const char *buf, size_t count){	struct f71805f_data *data = dev_get_drvdata(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int nr = attr->index;	long val = simple_strtol(buf, NULL, 10);	mutex_lock(&data->update_lock);	data->temp_high[nr] = temp_to_reg(val);	f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]);	mutex_unlock(&data->update_lock);	return count;}static ssize_t set_temp_hyst(struct device *dev, struct device_attribute			     *devattr, const char *buf, size_t count){	struct f71805f_data *data = dev_get_drvdata(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int nr = attr->index;	long val = simple_strtol(buf, NULL, 10);	mutex_lock(&data->update_lock);	data->temp_hyst[nr] = temp_to_reg(val);	f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]);	mutex_unlock(&data->update_lock);	return count;}static ssize_t show_alarms_in(struct device *dev, struct device_attribute			      *devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	return sprintf(buf, "%lu\n", data->alarms & 0x7ff);}static ssize_t show_alarms_fan(struct device *dev, struct device_attribute			       *devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	return sprintf(buf, "%lu\n", (data->alarms >> 16) & 0x07);}static ssize_t show_alarms_temp(struct device *dev, struct device_attribute				*devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	return sprintf(buf, "%lu\n", (data->alarms >> 11) & 0x07);}static ssize_t show_alarm(struct device *dev, struct device_attribute			  *devattr, char *buf){	struct f71805f_data *data = f71805f_update_device(dev);	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);	int bitnr = attr->index;	return sprintf(buf, "%lu\n", (data->alarms >> bitnr) & 1);}static ssize_t show_name(struct device *dev, struct device_attribute			 *devattr, char *buf){	struct f71805f_data *data = dev_get_drvdata(dev);	return sprintf(buf, "%s\n", data->name);}static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0);static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR,			  show_in0_max, set_in0_max, 0);static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR,			  show_in0_min, set_in0_min, 0);static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1);static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 1);static SENSOR_DEVICE_ATTR(in1_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 1);static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2);static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 2);static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 2);static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3);static SENSOR_DEVICE_ATTR(in3_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 3);static SENSOR_DEVICE_ATTR(in3_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 3);static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4);static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 4);static SENSOR_DEVICE_ATTR(in4_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 4);static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in, NULL, 5);static SENSOR_DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 5);static SENSOR_DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 5);static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_in, NULL, 6);static SENSOR_DEVICE_ATTR(in6_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 6);static SENSOR_DEVICE_ATTR(in6_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 6);static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_in, NULL, 7);static SENSOR_DEVICE_ATTR(in7_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 7);static SENSOR_DEVICE_ATTR(in7_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 7);static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_in, NULL, 8);static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR,			  show_in_max, set_in_max, 8);static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR,			  show_in_min, set_in_min, 8);static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_in0, NULL, 9);static SENSOR_DEVICE_ATTR(in9_max, S_IRUGO | S_IWUSR,			  show_in0_max, set_in0_max, 9);static SENSOR_DEVICE_ATTR(in9_min, S_IRUGO | S_IWUSR,			  show_in0_min, set_in0_min, 9);static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_in0, NULL, 10);static SENSOR_DEVICE_ATTR(in10_max, S_IRUGO | S_IWUSR,			  show_in0_max, set_in0_max, 10);static SENSOR_DEVICE_ATTR(in10_min, S_IRUGO | S_IWUSR,			  show_in0_min, set_in0_min, 10);static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR,			  show_fan_min, set_fan_min, 0);static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR,			  show_fan_target, set_fan_target, 0);static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR,			  show_fan_min, set_fan_min, 1);static SENSOR_DEVICE_ATTR(fan2_target, S_IRUGO | S_IWUSR,			  show_fan_target, set_fan_target, 1);static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR,			  show_fan_min, set_fan_min, 2);static SENSOR_DEVICE_ATTR(fan3_target, S_IRUGO | S_IWUSR,			  show_fan_target, set_fan_target, 2);static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,		    show_temp_max, set_temp_max, 0);static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,		    show_temp_hyst, set_temp_hyst, 0);static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0);static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR,		    show_temp_max, set_temp_max, 1);static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR,		    show_temp_hyst, set_temp_hyst, 1);static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1);static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR,		    show_temp_max, set_temp_max, 2);static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR,		    show_temp_hyst, set_temp_hyst, 2);static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2);/* pwm (value) files are created read-only, write permission is   then added or removed dynamically as needed */static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0);static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,			  show_pwm_enable, set_pwm_enable, 0);static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO | S_IWUSR,			  show_pwm_freq, set_pwm_freq, 0);static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0);static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO, show_pwm, set_pwm, 1);static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR,			  show_pwm_enable, set_pwm_enable, 1);static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO | S_IWUSR,			  show_pwm_freq, set_pwm_freq, 1);static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1);static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO, show_pwm, set_pwm, 2);static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR,			  show_pwm_enable, set_pwm_enable, 2);static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO | S_IWUSR,			  show_pwm_freq, set_pwm_freq, 2);static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2);static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    0, 0);static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    0, 0);static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    0, 1);static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    0, 1);static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    0, 2);static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    0, 2);static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    1, 0);static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    1, 0);static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    1, 1);static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    1, 1);static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    1, 2);static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    1, 2);static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    2, 0);static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    2, 0);static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    2, 1);static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    2, 1);static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_temp, set_pwm_auto_point_temp,			    2, 2);static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_fan, S_IRUGO | S_IWUSR,			    show_pwm_auto_point_fan, set_pwm_auto_point_fan,			    2, 2);static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4);static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5);static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6);static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7);static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8);static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 9);static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 10);static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11);static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12);static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16);static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17);static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18);static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL);static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL);static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);static struct attribute *f71805f_attributes[] = {	&sensor_dev_attr_in0_input.dev_attr.attr,	&sensor_dev_attr_in0_max.dev_attr.attr,	&sensor_dev_attr_in0_min.dev_attr.attr,	&sensor_dev_attr_in1_input.dev_attr.attr,	&sensor_dev_attr_in1_max.dev_attr.attr,	&sensor_dev_attr_in1_min.dev_attr.attr,	&sensor_dev_attr_in2_input.dev_attr.attr,	&sensor_dev_attr_in2_max.dev_attr.attr,	&sensor_dev_attr_in2_min.dev_attr.attr,	&sensor_dev_attr_in3_input.dev_attr.attr,	&sensor_dev_attr_in3_max.dev_attr.attr,	&sensor_dev_attr_in3_min.dev_attr.attr,	&sensor_dev_attr_in5_input.dev_attr.attr,	&sensor_dev_attr_in5_max.dev_attr.attr,	&sensor_dev_attr_in5_min.dev_attr.attr,	&sensor_dev_attr_in6_input.dev_attr.attr,	&sensor_dev_attr_in6_max.dev_attr.attr,	&sensor_dev_attr_in6_min.dev_attr.attr,	&sensor_dev_attr_in7_input.dev_attr.attr,	&sensor_dev_attr_in7_max.dev_attr.attr,	&sensor_dev_attr_in7_min.dev_attr.attr,	&sensor_dev_attr_fan1_input.dev_attr.attr,	&sensor_dev_attr_fan1_min.dev_attr.attr,	&sensor_dev_attr_fan1_alarm.dev_attr.attr,	&sensor_dev_attr_fan1_target.dev_attr.attr,	&sensor_dev_attr_fan2_input.dev_attr.attr,	&sensor_dev_attr_fan2_min.dev_attr.attr,	&sensor_dev_attr_fan2_alarm.dev_attr.attr,	&sensor_dev_attr_fan2_target.dev_attr.attr,	&sensor_dev_attr_fan3_input.dev_attr.attr,	&sensor_dev_attr_fan3_min.dev_attr.attr,	&sensor_dev_attr_fan3_alarm.dev_attr.attr,	&sensor_dev_attr_fan3_target.dev_attr.attr,	&sensor_dev_attr_pwm1.dev_attr.attr,	&sensor_dev_attr_pwm1_enable.dev_attr.attr,	&sensor_dev_attr_pwm1_mode.dev_attr.attr,	&sensor_dev_attr_pwm2.dev_attr.attr,	&sensor_dev_attr_pwm2_enable.dev_attr.attr,	&sensor_dev_attr_pwm2_mode.dev_attr.attr,	&sensor_dev_attr_pwm3.dev_attr.attr,	&sensor_dev_attr_pwm3_enable.dev_attr.attr,	&sensor_dev_attr_pwm3_mode.dev_attr.attr,	&sensor_dev_attr_temp1_input.dev_attr.attr,	&sensor_dev_attr_temp1_max.dev_attr.attr,	&sensor_dev_attr_temp1_max_hyst.dev_attr.attr,	&sensor_dev_attr_temp1_type.dev_attr.attr,	&sensor_dev_attr_temp2_input.dev_attr.attr,	&sensor_dev_attr_temp2_max.dev_attr.attr,	&sensor_dev_attr_temp2_max_hyst.dev_attr.attr,	&sensor_dev_attr_temp2_type.dev_attr.attr,	&sensor_dev_attr_temp3_input.dev_attr.attr,	&sensor_dev_attr_temp3_max.dev_attr.attr,	&sensor_dev_attr_temp3_max_hyst.dev_attr.attr,	&sensor_dev_attr_temp3_type.dev_attr.attr,	&sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr,	&sensor_dev_attr_pwm1_auto_point1_fan.dev_attr.attr,	&sensor_dev_attr_pwm1_auto_point2_temp.dev_attr.attr,	&sensor_dev_attr_pwm1_auto_point2_fan.dev_attr.attr,	&sensor_dev_attr_pwm1_auto_point3_temp.dev_attr.attr,	&sensor_dev_attr_pwm1_auto_point3_fan.dev_attr.attr,	&sensor_dev_attr_pwm2_auto_point1_temp.dev_attr.attr,	&sensor_dev_attr_pwm2_auto_point1_fan.dev_attr.attr,	&sensor_dev_attr_pwm2_auto_point2_temp.dev_attr.attr,	&sensor_dev_attr_pwm2_auto_point2_fan.dev_attr.attr,	&sensor_dev_attr_pwm2_auto_point3_temp.dev_attr.attr,	&sensor_dev_attr_pwm2_auto_point3_fan.dev_attr.attr,	&sensor_dev_attr_pwm3_auto_point1_temp.dev_attr.attr,	&sensor_dev_attr_pwm3_auto_point1_fan.dev_attr.attr,	&sensor_dev_attr_pwm3_auto_point2_temp.dev_attr.attr,	&sensor_dev_attr_pwm3_auto_point2_fan.dev_attr.attr,	&sensor_dev_attr_pwm3_auto_point3_temp.dev_attr.attr,	&sensor_dev_attr_pwm3_auto_point3_fan.dev_attr.attr,	&sensor_dev_attr_in0_alarm.dev_attr.attr,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -