[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.3 / 0063-hwmon-f71805f-Fix-clamping-of-temperature-limits.patch
1 From bdf8cb4ebb0c6f8e60c3900cdc34289b4e3ca924 Mon Sep 17 00:00:00 2001
2 From: Jean Delvare <khali@linux-fr.org>
3 Date: Fri, 20 Jan 2012 10:09:23 -0500
4 Subject: [PATCH 63/90] hwmon: (f71805f) Fix clamping of temperature limits
6 commit 86b2bbfdbd1fcc4a3aa62ccd3f245c40c5ad5b85 upstream.
8 Properly clamp temperature limits set by the user. Without this fix,
9 attempts to write temperature limits above the maximum supported by
10 the chip (255 degrees Celsius) would arbitrarily and unexpectedly
11 result in the limit being set to 0 degree Celsius.
13 Signed-off-by: Jean Delvare <khali@linux-fr.org>
14 Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 ---
17 drivers/hwmon/f71805f.c | 10 +++++-----
18 1 file changed, 5 insertions(+), 5 deletions(-)
20 diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
21 index 92f9497..6dbfd3e 100644
22 --- a/drivers/hwmon/f71805f.c
23 +++ b/drivers/hwmon/f71805f.c
24 @@ -283,11 +283,11 @@ static inline long temp_from_reg(u8 reg)
26 static inline u8 temp_to_reg(long val)
27 {
28 - if (val < 0)
29 - val = 0;
30 - else if (val > 1000 * 0xff)
31 - val = 0xff;
32 - return ((val + 500) / 1000);
33 + if (val <= 0)
34 + return 0;
35 + if (val >= 1000 * 0xff)
36 + return 0xff;
37 + return (val + 500) / 1000;
38 }
40 /*
41 --
42 1.7.9.4