Skip to content

Commit

Permalink
hwmon: (f71805f) Fix clamping of temperature limits
Browse files Browse the repository at this point in the history
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: Jean Delvare <khali@linux-fr.org>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
  • Loading branch information
Jean Delvare authored and Guenter Roeck committed Jan 20, 2012
1 parent dcd6c92 commit 86b2bbf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/hwmon/f71805f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 86b2bbf

Please sign in to comment.