Commit 543c6a0b authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman

hwmon: (f71805f) Fix clamping of temperature limits

commit 86b2bbfd upstream.

Properly clamp temperature limits set by the user. Without this fix,
attempts to write temperature limits above the maximum supported by
the chip (255 degrees Celsius) would arbitrarily and unexpectedly
result in the limit being set to 0 degree Celsius.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8df2b756
......@@ -283,11 +283,11 @@ static inline long temp_from_reg(u8 reg)
static inline u8 temp_to_reg(long val)
{
if (val < 0)
val = 0;
else if (val > 1000 * 0xff)
val = 0xff;
return ((val + 500) / 1000);
if (val <= 0)
return 0;
if (val >= 1000 * 0xff)
return 0xff;
return (val + 500) / 1000;
}
/*
......
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