diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-07-16 20:40:31 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-07-17 00:18:47 -0400 |
commit | de12d6f4b10b21854441f5242dcb29ea96181e58 (patch) | |
tree | bd197e8e568310bb71c6469f7d9242ed8b056df1 /drivers/hwmon/adt7470.c | |
parent | 6b00f440dd678d786389a7100a2e03fe44478431 (diff) |
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: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org
Reviewed-by: Axel Lin <axel.lin@ingics.com>
Diffstat (limited to 'drivers/hwmon/adt7470.c')
-rw-r--r-- | drivers/hwmon/adt7470.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 0f4dea5ccf17..9ee3913850d6 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c | |||
@@ -515,7 +515,7 @@ static ssize_t set_temp_min(struct device *dev, | |||
515 | return -EINVAL; | 515 | return -EINVAL; |
516 | 516 | ||
517 | temp = DIV_ROUND_CLOSEST(temp, 1000); | 517 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
518 | temp = clamp_val(temp, 0, 255); | 518 | temp = clamp_val(temp, -128, 127); |
519 | 519 | ||
520 | mutex_lock(&data->lock); | 520 | mutex_lock(&data->lock); |
521 | data->temp_min[attr->index] = temp; | 521 | data->temp_min[attr->index] = temp; |
@@ -549,7 +549,7 @@ static ssize_t set_temp_max(struct device *dev, | |||
549 | return -EINVAL; | 549 | return -EINVAL; |
550 | 550 | ||
551 | temp = DIV_ROUND_CLOSEST(temp, 1000); | 551 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
552 | temp = clamp_val(temp, 0, 255); | 552 | temp = clamp_val(temp, -128, 127); |
553 | 553 | ||
554 | mutex_lock(&data->lock); | 554 | mutex_lock(&data->lock); |
555 | data->temp_max[attr->index] = temp; | 555 | data->temp_max[attr->index] = temp; |
@@ -826,7 +826,7 @@ static ssize_t set_pwm_tmin(struct device *dev, | |||
826 | return -EINVAL; | 826 | return -EINVAL; |
827 | 827 | ||
828 | temp = DIV_ROUND_CLOSEST(temp, 1000); | 828 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
829 | temp = clamp_val(temp, 0, 255); | 829 | temp = clamp_val(temp, -128, 127); |
830 | 830 | ||
831 | mutex_lock(&data->lock); | 831 | mutex_lock(&data->lock); |
832 | data->pwm_tmin[attr->index] = temp; | 832 | data->pwm_tmin[attr->index] = temp; |