summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2012-01-20 10:09:23 -0500
committerSimone Willett <swillett@nvidia.com>2012-02-08 14:06:40 -0800
commit0a640fcaa91dd17f552620aad7a5e301f5f373c9 (patch)
tree1076b585f2e33bcdbc926da752ba78181c8480e4 /drivers/hwmon
parent584c40e8634c0613d8e025489a71fb5218543890 (diff)
hwmon: (f71805f) Fix clamping of temperature limits
commit 86b2bbfdbd1fcc4a3aa62ccd3f245c40c5ad5b85 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: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Change-Id: I7706baf5766f7597b458a62809e147d0dd2ee164 Reviewed-on: http://git-master/r/79683 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/f71805f.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 92f949767ece..6dbfd3e516e4 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -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;
}
/*