hwmon: (adt7470) Fix writes to temperature limit registers
Guenter Roeck
maintainerPATCH v2 1/1 hwmon: (adt7470) Fix writes to temperature limit registers
Fyi, forgot to copy you. Unrelated to your patch, found in module test.
Guenter
-------- Original Message --------
Subject: [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers
Date: Wed, 16 Jul 2014 18:08:56 -0700
From: Guenter Roeck <[email protected]>
To: lm-sensors <[email protected]>
CC: Jean Delvare <[email protected]>, Guenter Roeck <[email protected]>
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.
---
v2: Apply to pwm[1-4]_auto_point1_temp as well. While the datasheet
does not state clearly that the register is signed, anything else does not really make sense. Either case, since the data is stored as s8, the bug as described applies to this register as well.
drivers/hwmon/adt7470.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwmon/adt7470.c +3 -3
@@ -515,7 +515,7 @@ static ssize_t set_temp_min(struct device *dev,return -EINVAL ; temp =DIV_ROUND_CLOSEST (temp,1000 ); - temp =clamp_val (temp,0 ,255 ); + temp =clamp_val (temp,-128 ,127 );mutex_lock (&data->lock); data->temp_min[attr->index] = temp;
@@ -549,7 +549,7 @@ static ssize_t set_temp_max(struct device *dev,return -EINVAL ; temp =DIV_ROUND_CLOSEST (temp,1000 ); - temp =clamp_val (temp,0 ,255 ); + temp =clamp_val (temp,-128 ,127 );mutex_lock (&data->lock); data->temp_max[attr->index] = temp;
@@ -826,7 +826,7 @@ static ssize_t set_pwm_tmin(struct device *dev,return -EINVAL ; temp =DIV_ROUND_CLOSEST (temp,1000 ); - temp =clamp_val (temp,0 ,255 ); + temp =clamp_val (temp,-128 ,127 );mutex_lock (&data->lock); data->pwm_tmin[attr->index] = temp;
Signature · 11 lines
1.9.1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors