* [lm-sensors] [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers
@ 2014-07-17 1:08 Guenter Roeck
2014-07-17 4:15 ` Axel Lin
2014-07-17 4:21 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2014-07-17 1:08 UTC (permalink / raw)
To: lm-sensors
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>
---
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(-)
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 0f4dea5..9ee3913 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -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;
--
1.9.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [lm-sensors] [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers
2014-07-17 1:08 [lm-sensors] [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers Guenter Roeck
@ 2014-07-17 4:15 ` Axel Lin
2014-07-17 4:21 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2014-07-17 4:15 UTC (permalink / raw)
To: lm-sensors
2014-07-17 12:06 GMT+08:00 Guenter Roeck <linux@roeck-us.net>:
> Fyi, forgot to copy you. Unrelated to your patch, found in module test.
>
Thanks, Guenter.
The patch looks good to me,
Reviewed-by: Axel Lin <axel.lin@ingics.com>
Axel
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers
2014-07-17 1:08 [lm-sensors] [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers Guenter Roeck
2014-07-17 4:15 ` Axel Lin
@ 2014-07-17 4:21 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2014-07-17 4:21 UTC (permalink / raw)
To: lm-sensors
On 07/16/2014 09:15 PM, Axel Lin wrote:
> 2014-07-17 12:06 GMT+08:00 Guenter Roeck <linux@roeck-us.net>:
>> Fyi, forgot to copy you. Unrelated to your patch, found in module test.
>>
> Thanks, Guenter.
> The patch looks good to me,
> Reviewed-by: Axel Lin <axel.lin@ingics.com>
>
Thanks for all your work!
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-17 4:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-17 1:08 [lm-sensors] [PATCH v2] hwmon: (adt7470) Fix writes to temperature limit registers Guenter Roeck
2014-07-17 4:15 ` Axel Lin
2014-07-17 4:21 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.