Commit de12d6f4 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (adt7470) Fix writes to temperature limit registers

Temperature limit registers are signed. Limits therefore need
to be clamped to (-128, 127) degrees C and not to (0, 255)
degrees C.

Without this fix, writing a limit of 128 degrees C sets the
actual limit to -128 degrees C.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarAxel Lin <axel.lin@ingics.com>
parent 6b00f440
...@@ -515,7 +515,7 @@ static ssize_t set_temp_min(struct device *dev, ...@@ -515,7 +515,7 @@ static ssize_t set_temp_min(struct device *dev,
return -EINVAL; return -EINVAL;
temp = DIV_ROUND_CLOSEST(temp, 1000); temp = DIV_ROUND_CLOSEST(temp, 1000);
temp = clamp_val(temp, 0, 255); temp = clamp_val(temp, -128, 127);
mutex_lock(&data->lock); mutex_lock(&data->lock);
data->temp_min[attr->index] = temp; data->temp_min[attr->index] = temp;
...@@ -549,7 +549,7 @@ static ssize_t set_temp_max(struct device *dev, ...@@ -549,7 +549,7 @@ static ssize_t set_temp_max(struct device *dev,
return -EINVAL; return -EINVAL;
temp = DIV_ROUND_CLOSEST(temp, 1000); temp = DIV_ROUND_CLOSEST(temp, 1000);
temp = clamp_val(temp, 0, 255); temp = clamp_val(temp, -128, 127);
mutex_lock(&data->lock); mutex_lock(&data->lock);
data->temp_max[attr->index] = temp; data->temp_max[attr->index] = temp;
...@@ -826,7 +826,7 @@ static ssize_t set_pwm_tmin(struct device *dev, ...@@ -826,7 +826,7 @@ static ssize_t set_pwm_tmin(struct device *dev,
return -EINVAL; return -EINVAL;
temp = DIV_ROUND_CLOSEST(temp, 1000); temp = DIV_ROUND_CLOSEST(temp, 1000);
temp = clamp_val(temp, 0, 255); temp = clamp_val(temp, -128, 127);
mutex_lock(&data->lock); mutex_lock(&data->lock);
data->pwm_tmin[attr->index] = temp; data->pwm_tmin[attr->index] = temp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment