forked from mirrors/linux
		
	hwmon: (pc87360) Fix checkpatch issues
Fixed:
ERROR: code indent should use tabs where possible
ERROR: do not use assignment in if condition
ERROR: "foo * bar" should be "foo *bar"
ERROR: space required after that ',' (ctx:VxV)
ERROR: spaces required around that ':' (ctx:VxE)
ERROR: spaces required around that '==' (ctx:VxV)
WARNING: braces {} are not necessary for single statement blocks
WARNING: line over 80 characters
WARNING: please, no space before tabs
WARNING: please, no spaces at the start of a line
WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: simple_strtoul is obsolete, use kstrtoul instead
Not or not all fixed (code complexity):
ERROR: Macros with complex values should be enclosed in parenthesis
ERROR: do not use assignment in if condition
Cc: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
			
			
This commit is contained in:
		
							parent
							
								
									8958dfb74a
								
							
						
					
					
						commit
						449a7a0720
					
				
					 1 changed files with 260 additions and 144 deletions
				
			
		|  | @ -126,12 +126,12 @@ static inline void superio_exit(int sioaddr) | |||
| 					 480000 / ((val) * (div))) | ||||
| #define FAN_TO_REG(val, div)		((val) <= 100 ? 0 : \ | ||||
| 					 480000 / ((val) * (div))) | ||||
| #define FAN_DIV_FROM_REG(val)		(1 << ((val >> 5) & 0x03)) | ||||
| #define FAN_DIV_FROM_REG(val)		(1 << (((val) >> 5) & 0x03)) | ||||
| #define FAN_STATUS_FROM_REG(val)	((val) & 0x07) | ||||
| 
 | ||||
| #define FAN_CONFIG_MONITOR(val,nr)	(((val) >> (2 + nr * 3)) & 1) | ||||
| #define FAN_CONFIG_CONTROL(val,nr)	(((val) >> (3 + nr * 3)) & 1) | ||||
| #define FAN_CONFIG_INVERT(val,nr)	(((val) >> (4 + nr * 3)) & 1) | ||||
| #define FAN_CONFIG_MONITOR(val, nr)	(((val) >> (2 + (nr) * 3)) & 1) | ||||
| #define FAN_CONFIG_CONTROL(val, nr)	(((val) >> (3 + (nr) * 3)) & 1) | ||||
| #define FAN_CONFIG_INVERT(val, nr)	(((val) >> (4 + (nr) * 3)) & 1) | ||||
| 
 | ||||
| #define PWM_FROM_REG(val, inv)		((inv) ? 255 - (val) : (val)) | ||||
| static inline u8 PWM_TO_REG(int val, int inv) | ||||
|  | @ -255,43 +255,54 @@ static struct platform_driver pc87360_driver = { | |||
|  * Sysfs stuff | ||||
|  */ | ||||
| 
 | ||||
| static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_fan_input(struct device *dev, | ||||
| 			      struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index], | ||||
| 		       FAN_DIV_FROM_REG(data->fan_status[attr->index]))); | ||||
| } | ||||
| static ssize_t show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_fan_min(struct device *dev, | ||||
| 			    struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index], | ||||
| 		       FAN_DIV_FROM_REG(data->fan_status[attr->index]))); | ||||
| } | ||||
| static ssize_t show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_fan_div(struct device *dev, | ||||
| 			    struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", | ||||
| 		       FAN_DIV_FROM_REG(data->fan_status[attr->index])); | ||||
| } | ||||
| static ssize_t show_fan_status(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_fan_status(struct device *dev, | ||||
| 			       struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", | ||||
| 		       FAN_STATUS_FROM_REG(data->fan_status[attr->index])); | ||||
| } | ||||
| static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| static ssize_t set_fan_min(struct device *dev, | ||||
| 			   struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long fan_min = simple_strtol(buf, NULL, 10); | ||||
| 	long fan_min; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &fan_min); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); | ||||
| 	fan_min = FAN_TO_REG(fan_min, | ||||
| 			     FAN_DIV_FROM_REG(data->fan_status[attr->index])); | ||||
| 
 | ||||
| 	/* If it wouldn't fit, change clock divisor */ | ||||
| 	while (fan_min > 255 | ||||
|  | @ -301,11 +312,13 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
| 		data->fan_status[attr->index] += 0x20; | ||||
| 	} | ||||
| 	data->fan_min[attr->index] = fan_min > 255 ? 255 : fan_min; | ||||
| 	pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(attr->index), | ||||
| 	pc87360_write_value(data, LD_FAN, NO_BANK, | ||||
| 			    PC87360_REG_FAN_MIN(attr->index), | ||||
| 			    data->fan_min[attr->index]); | ||||
| 
 | ||||
| 	/* Write new divider, preserve alarm bits */ | ||||
| 	pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), | ||||
| 	pc87360_write_value(data, LD_FAN, NO_BANK, | ||||
| 			    PC87360_REG_FAN_STATUS(attr->index), | ||||
| 			    data->fan_status[attr->index] & 0xF9); | ||||
| 	mutex_unlock(&data->update_lock); | ||||
| 
 | ||||
|  | @ -339,7 +352,8 @@ static struct sensor_device_attribute fan_min[] = { | |||
| 	&fan_div[X].dev_attr.attr,	\ | ||||
| 	&fan_min[X].dev_attr.attr | ||||
| 
 | ||||
| static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, | ||||
| 			char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
|  | @ -348,12 +362,17 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, ch | |||
| 				    FAN_CONFIG_INVERT(data->fan_conf, | ||||
| 						      attr->index))); | ||||
| } | ||||
| static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, | ||||
| 		       const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->pwm[attr->index] = PWM_TO_REG(val, | ||||
|  | @ -383,39 +402,48 @@ static const struct attribute_group pc8736x_fan_group = { | |||
| 	.attrs = pc8736x_fan_attr_array, | ||||
| }; | ||||
| 
 | ||||
| static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_in_input(struct device *dev, | ||||
| 			     struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_in_min(struct device *dev, | ||||
| 			   struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_in_max(struct device *dev, | ||||
| 			   struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_in_status(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_in_status(struct device *dev, | ||||
| 			      struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", data->in_status[attr->index]); | ||||
| } | ||||
| static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, | ||||
| 			  const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | ||||
|  | @ -424,12 +452,17 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, | |||
| 	mutex_unlock(&data->update_lock); | ||||
| 	return count; | ||||
| } | ||||
| static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, | ||||
| 			  const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->in_max[attr->index] = IN_TO_REG(val, | ||||
|  | @ -556,27 +589,38 @@ static struct sensor_device_attribute in_max_alarm[] = { | |||
| 	&in_min_alarm[X].dev_attr.attr,	\ | ||||
| 	&in_max_alarm[X].dev_attr.attr | ||||
| 
 | ||||
| static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | ||||
| static ssize_t show_vid(struct device *dev, struct device_attribute *attr, | ||||
| 			char *buf) | ||||
| { | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); | ||||
| } | ||||
| static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||||
| 
 | ||||
| static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) | ||||
| static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, | ||||
| 			char *buf) | ||||
| { | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	return sprintf(buf, "%u\n", data->vrm); | ||||
| } | ||||
| static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||||
| static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, | ||||
| 		       const char *buf, size_t count) | ||||
| { | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	data->vrm = simple_strtoul(buf, NULL, 10); | ||||
| 	unsigned long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtoul(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	data->vrm = val; | ||||
| 	return count; | ||||
| } | ||||
| static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); | ||||
| 
 | ||||
| static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr, char *buf) | ||||
| static ssize_t show_in_alarms(struct device *dev, | ||||
| 			      struct device_attribute *attr, char *buf) | ||||
| { | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", data->in_alarms); | ||||
|  | @ -604,46 +648,58 @@ static const struct attribute_group pc8736x_vin_group = { | |||
| 	.attrs = pc8736x_vin_attr_array, | ||||
| }; | ||||
| 
 | ||||
| static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_therm_input(struct device *dev, | ||||
| 				struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_therm_min(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_therm_min(struct device *dev, | ||||
| 			      struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_therm_max(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_therm_max(struct device *dev, | ||||
| 			      struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_therm_crit(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_therm_crit(struct device *dev, | ||||
| 			       struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-11], | ||||
| 		       data->in_vref)); | ||||
| } | ||||
| static ssize_t show_therm_status(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_therm_status(struct device *dev, | ||||
| 				 struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", data->in_status[attr->index]); | ||||
| } | ||||
| static ssize_t set_therm_min(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| 
 | ||||
| static ssize_t set_therm_min(struct device *dev, | ||||
| 			     struct device_attribute *devattr, | ||||
| 			     const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | ||||
|  | @ -652,12 +708,19 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt | |||
| 	mutex_unlock(&data->update_lock); | ||||
| 	return count; | ||||
| } | ||||
| static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| 
 | ||||
| static ssize_t set_therm_max(struct device *dev, | ||||
| 			     struct device_attribute *devattr, | ||||
| 			     const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); | ||||
|  | @ -666,12 +729,18 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt | |||
| 	mutex_unlock(&data->update_lock); | ||||
| 	return count; | ||||
| } | ||||
| static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| static ssize_t set_therm_crit(struct device *dev, | ||||
| 			      struct device_attribute *devattr, | ||||
| 			      const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); | ||||
|  | @ -795,42 +864,59 @@ static const struct attribute_group pc8736x_therm_group = { | |||
| 	.attrs = pc8736x_therm_attr_array, | ||||
| }; | ||||
| 
 | ||||
| static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| static ssize_t show_temp_input(struct device *dev, | ||||
| 			       struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); | ||||
| } | ||||
| static ssize_t show_temp_min(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| 
 | ||||
| static ssize_t show_temp_min(struct device *dev, | ||||
| 			     struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index])); | ||||
| } | ||||
| static ssize_t show_temp_max(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| 
 | ||||
| static ssize_t show_temp_max(struct device *dev, | ||||
| 			     struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index])); | ||||
| } | ||||
| static ssize_t show_temp_crit(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| 
 | ||||
| static ssize_t show_temp_crit(struct device *dev, | ||||
| 			      struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[attr->index])); | ||||
| 	return sprintf(buf, "%d\n", | ||||
| 		       TEMP_FROM_REG(data->temp_crit[attr->index])); | ||||
| } | ||||
| static ssize_t show_temp_status(struct device *dev, struct device_attribute *devattr, char *buf) | ||||
| 
 | ||||
| static ssize_t show_temp_status(struct device *dev, | ||||
| 				struct device_attribute *devattr, char *buf) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%d\n", data->temp_status[attr->index]); | ||||
| } | ||||
| static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| 
 | ||||
| static ssize_t set_temp_min(struct device *dev, | ||||
| 			    struct device_attribute *devattr, | ||||
| 			    const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->temp_min[attr->index] = TEMP_TO_REG(val); | ||||
|  | @ -839,12 +925,19 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr | |||
| 	mutex_unlock(&data->update_lock); | ||||
| 	return count; | ||||
| } | ||||
| static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 	size_t count) | ||||
| 
 | ||||
| static ssize_t set_temp_max(struct device *dev, | ||||
| 			    struct device_attribute *devattr, | ||||
| 			    const char *buf, size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->temp_max[attr->index] = TEMP_TO_REG(val); | ||||
|  | @ -853,12 +946,19 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr | |||
| 	mutex_unlock(&data->update_lock); | ||||
| 	return count; | ||||
| } | ||||
| static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | ||||
| 
 | ||||
| static ssize_t set_temp_crit(struct device *dev, | ||||
| 			     struct device_attribute *devattr, const char *buf, | ||||
| 			     size_t count) | ||||
| { | ||||
| 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	long val = simple_strtol(buf, NULL, 10); | ||||
| 	long val; | ||||
| 	int err; | ||||
| 
 | ||||
| 	err = kstrtol(buf, 10, &val); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 
 | ||||
| 	mutex_lock(&data->update_lock); | ||||
| 	data->temp_crit[attr->index] = TEMP_TO_REG(val); | ||||
|  | @ -903,11 +1003,13 @@ static struct sensor_device_attribute temp_crit[] = { | |||
| 		    show_temp_crit, set_temp_crit, 2), | ||||
| }; | ||||
| 
 | ||||
| static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) | ||||
| static ssize_t show_temp_alarms(struct device *dev, | ||||
| 				struct device_attribute *attr, char *buf) | ||||
| { | ||||
| 	struct pc87360_data *data = pc87360_update_device(dev); | ||||
| 	return sprintf(buf, "%u\n", data->temp_alarms); | ||||
| } | ||||
| 
 | ||||
| static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -924,6 +1026,7 @@ static ssize_t show_temp_min_alarm(struct device *dev, | |||
| 
 | ||||
| 	return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MIN)); | ||||
| } | ||||
| 
 | ||||
| static ssize_t show_temp_max_alarm(struct device *dev, | ||||
| 			struct device_attribute *devattr, char *buf) | ||||
| { | ||||
|  | @ -932,6 +1035,7 @@ static ssize_t show_temp_max_alarm(struct device *dev, | |||
| 
 | ||||
| 	return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MAX)); | ||||
| } | ||||
| 
 | ||||
| static ssize_t show_temp_crit_alarm(struct device *dev, | ||||
| 			struct device_attribute *devattr, char *buf) | ||||
| { | ||||
|  | @ -946,11 +1050,13 @@ static struct sensor_device_attribute temp_min_alarm[] = { | |||
| 	SENSOR_ATTR(temp2_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 1), | ||||
| 	SENSOR_ATTR(temp3_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 2), | ||||
| }; | ||||
| 
 | ||||
| static struct sensor_device_attribute temp_max_alarm[] = { | ||||
| 	SENSOR_ATTR(temp1_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 0), | ||||
| 	SENSOR_ATTR(temp2_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 1), | ||||
| 	SENSOR_ATTR(temp3_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 2), | ||||
| }; | ||||
| 
 | ||||
| static struct sensor_device_attribute temp_crit_alarm[] = { | ||||
| 	SENSOR_ATTR(temp1_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 0), | ||||
| 	SENSOR_ATTR(temp2_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 1), | ||||
|  | @ -991,6 +1097,7 @@ static struct attribute * pc8736x_temp_attr_array[] = { | |||
| 	&dev_attr_alarms_temp.attr, | ||||
| 	NULL | ||||
| }; | ||||
| 
 | ||||
| static const struct attribute_group pc8736x_temp_group = { | ||||
| 	.attrs = pc8736x_temp_attr_array, | ||||
| }; | ||||
|  | @ -1001,13 +1108,15 @@ static ssize_t show_name(struct device *dev, | |||
| 	struct pc87360_data *data = dev_get_drvdata(dev); | ||||
| 	return sprintf(buf, "%s\n", data->name); | ||||
| } | ||||
| 
 | ||||
| static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | ||||
| 
 | ||||
| /*
 | ||||
|  * Device detection, registration and update | ||||
|  */ | ||||
| 
 | ||||
| static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses) | ||||
| static int __init pc87360_find(int sioaddr, u8 *devid, | ||||
| 			       unsigned short *addresses) | ||||
| { | ||||
| 	u16 val; | ||||
| 	int i; | ||||
|  | @ -1103,7 +1212,8 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
| 	int use_thermistors = 0; | ||||
| 	struct device *dev = &pdev->dev; | ||||
| 
 | ||||
| 	if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | ||||
| 	data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL); | ||||
| 	if (!data) | ||||
| 		return -ENOMEM; | ||||
| 
 | ||||
| 	data->fannr = 2; | ||||
|  | @ -1139,7 +1249,8 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
| 	platform_set_drvdata(pdev, data); | ||||
| 
 | ||||
| 	for (i = 0; i < LDNI_MAX; i++) { | ||||
| 		if (((data->address[i] = extra_isa[i])) | ||||
| 		data->address[i] = extra_isa[i]; | ||||
| 		if (data->address[i] | ||||
| 		 && !request_region(extra_isa[i], PC87360_EXTENT, | ||||
| 				    pc87360_driver.driver.name)) { | ||||
| 			dev_err(dev, "Region 0x%x-0x%x already " | ||||
|  | @ -1193,15 +1304,17 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
| 
 | ||||
| 	/* Register all-or-nothing sysfs groups */ | ||||
| 
 | ||||
| 	if (data->innr && | ||||
| 	    (err = sysfs_create_group(&dev->kobj, | ||||
| 				      &pc8736x_vin_group))) | ||||
| 	if (data->innr) { | ||||
| 		err = sysfs_create_group(&dev->kobj, &pc8736x_vin_group); | ||||
| 		if (err) | ||||
| 			goto ERROR3; | ||||
| 	} | ||||
| 
 | ||||
| 	if (data->innr == 14 && | ||||
| 	    (err = sysfs_create_group(&dev->kobj, | ||||
| 				      &pc8736x_therm_group))) | ||||
| 	if (data->innr == 14) { | ||||
| 		err = sysfs_create_group(&dev->kobj, &pc8736x_therm_group); | ||||
| 		if (err) | ||||
| 			goto ERROR3; | ||||
| 	} | ||||
| 
 | ||||
| 	/* create device attr-files for varying sysfs groups */ | ||||
| 
 | ||||
|  | @ -1227,7 +1340,8 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
| 					&temp_fault[i].dev_attr))) | ||||
| 				goto ERROR3; | ||||
| 		} | ||||
| 		if ((err = device_create_file(dev, &dev_attr_alarms_temp))) | ||||
| 		err = device_create_file(dev, &dev_attr_alarms_temp); | ||||
| 		if (err) | ||||
| 			goto ERROR3; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -1243,12 +1357,15 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
| 					&fan_status[i].dev_attr)))) | ||||
| 			goto ERROR3; | ||||
| 
 | ||||
| 		if (FAN_CONFIG_CONTROL(data->fan_conf, i) | ||||
| 		    && (err = device_create_file(dev, &pwm[i].dev_attr))) | ||||
| 		if (FAN_CONFIG_CONTROL(data->fan_conf, i)) { | ||||
| 			err = device_create_file(dev, &pwm[i].dev_attr); | ||||
| 			if (err) | ||||
| 				goto ERROR3; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if ((err = device_create_file(dev, &dev_attr_name))) | ||||
| 	err = device_create_file(dev, &dev_attr_name); | ||||
| 	if (err) | ||||
| 		goto ERROR3; | ||||
| 
 | ||||
| 	data->hwmon_dev = hwmon_device_register(dev); | ||||
|  | @ -1266,10 +1383,9 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
| 	sysfs_remove_group(&dev->kobj, &pc8736x_therm_group); | ||||
| 	sysfs_remove_group(&dev->kobj, &pc8736x_vin_group); | ||||
| 	for (i = 0; i < 3; i++) { | ||||
| 		if (data->address[i]) { | ||||
| 		if (data->address[i]) | ||||
| 			release_region(data->address[i], PC87360_EXTENT); | ||||
| 	} | ||||
| 	} | ||||
| ERROR1: | ||||
| 	kfree(data); | ||||
| 	return err; | ||||
|  | @ -1289,10 +1405,9 @@ static int __devexit pc87360_remove(struct platform_device *pdev) | |||
| 	sysfs_remove_group(&pdev->dev.kobj, &pc8736x_vin_group); | ||||
| 
 | ||||
| 	for (i = 0; i < 3; i++) { | ||||
| 		if (data->address[i]) { | ||||
| 		if (data->address[i]) | ||||
| 			release_region(data->address[i], PC87360_EXTENT); | ||||
| 	} | ||||
| 	} | ||||
| 	kfree(data); | ||||
| 
 | ||||
| 	return 0; | ||||
|  | @ -1394,8 +1509,8 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
| 		if (init >= init_temp[i]) { | ||||
| 			/* Forcibly enable temperature channel */ | ||||
| 			if (!(reg & CHAN_ENA)) { | ||||
| 				dev_dbg(&pdev->dev, "Forcibly " | ||||
| 					"enabling temp%d\n", i+1); | ||||
| 				dev_dbg(&pdev->dev, | ||||
| 					"Forcibly enabling temp%d\n", i + 1); | ||||
| 				pc87360_write_value(data, LD_TEMP, i, | ||||
| 						    PC87365_REG_TEMP_STATUS, | ||||
| 						    0xCF); | ||||
|  | @ -1413,9 +1528,9 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
| 				reg = pc87360_read_value(data, LD_TEMP, | ||||
| 				      (i - 11) / 2, PC87365_REG_TEMP_STATUS); | ||||
| 				if (reg & CHAN_ENA) { | ||||
| 					dev_dbg(&pdev->dev, "Skipping " | ||||
| 						"temp%d, pin already in use " | ||||
| 						"by temp%d\n", i-7, (i-11)/2); | ||||
| 					dev_dbg(&pdev->dev, | ||||
| 			"Skipping temp%d, pin already in use by temp%d\n", | ||||
| 						i - 7, (i - 11) / 2); | ||||
| 					continue; | ||||
| 				} | ||||
| 
 | ||||
|  | @ -1423,8 +1538,9 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
| 				reg = pc87360_read_value(data, LD_IN, i, | ||||
| 							 PC87365_REG_IN_STATUS); | ||||
| 				if (!(reg & CHAN_ENA)) { | ||||
| 					dev_dbg(&pdev->dev, "Forcibly " | ||||
| 						"enabling temp%d\n", i-7); | ||||
| 					dev_dbg(&pdev->dev, | ||||
| 						"Forcibly enabling temp%d\n", | ||||
| 						i - 7); | ||||
| 					pc87360_write_value(data, LD_IN, i, | ||||
| 						PC87365_REG_TEMP_STATUS, | ||||
| 						(reg & 0x60) | 0x8F); | ||||
|  | @ -1438,8 +1554,8 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
| 					 PC87365_REG_IN_CONFIG); | ||||
| 		dev_dbg(&pdev->dev, "bios vin-cfg:0x%02x\n", reg); | ||||
| 		if (reg & CHAN_ENA) { | ||||
| 			dev_dbg(&pdev->dev, "Forcibly " | ||||
| 				"enabling monitoring (VLM)\n"); | ||||
| 			dev_dbg(&pdev->dev, | ||||
| 				"Forcibly enabling monitoring (VLM)\n"); | ||||
| 			pc87360_write_value(data, LD_IN, NO_BANK, | ||||
| 					    PC87365_REG_IN_CONFIG, | ||||
| 					    reg & 0xFE); | ||||
|  | @ -1451,8 +1567,8 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
| 					 PC87365_REG_TEMP_CONFIG); | ||||
| 		dev_dbg(&pdev->dev, "bios temp-cfg:0x%02x\n", reg); | ||||
| 		if (reg & CHAN_ENA) { | ||||
| 			dev_dbg(&pdev->dev, "Forcibly enabling " | ||||
| 				"monitoring (TMS)\n"); | ||||
| 			dev_dbg(&pdev->dev, | ||||
| 				"Forcibly enabling monitoring (TMS)\n"); | ||||
| 			pc87360_write_value(data, LD_TEMP, NO_BANK, | ||||
| 					    PC87365_REG_TEMP_CONFIG, | ||||
| 					    reg & 0xFE); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Guenter Roeck
						Guenter Roeck