aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-10-20 03:06:45 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-10-20 10:17:08 -0400
commit133d324d82e144588939ad25b732b5b6c33b03d9 (patch)
tree752cba707cf1ea3914a1da31ac4caa8152aa8eeb
parent899e3ee404961a90b828ad527573aaaac39f0ab1 (diff)
hwmon: (w83627ehf) Fix negative 8-bit temperature values
Since 8-bit temperature values are now handled in 16-bit struct members, values have to be cast to s8 for negative temperatures to be properly handled. This is broken since kernel version 2.6.39 (commit bce26c58df86599c9570cee83eac58bdaae760e4.) Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Guenter Roeck <guenter.roeck@ericsson.com> Cc: stable@kernel.org # 2.6.39+ Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
-rw-r--r--drivers/hwmon/w83627ehf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 7b0260dc76fb..36d7f270b14d 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -390,7 +390,7 @@ temp_from_reg(u16 reg, s16 regval)
390{ 390{
391 if (is_word_sized(reg)) 391 if (is_word_sized(reg))
392 return LM75_TEMP_FROM_REG(regval); 392 return LM75_TEMP_FROM_REG(regval);
393 return regval * 1000; 393 return ((s8)regval) * 1000;
394} 394}
395 395
396static inline u16 396static inline u16
@@ -398,7 +398,8 @@ temp_to_reg(u16 reg, long temp)
398{ 398{
399 if (is_word_sized(reg)) 399 if (is_word_sized(reg))
400 return LM75_TEMP_TO_REG(temp); 400 return LM75_TEMP_TO_REG(temp);
401 return DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, -127000, 128000), 1000); 401 return (s8)DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, -127000, 128000),
402 1000);
402} 403}
403 404
404/* Some of analog inputs have internal scaling (2x), 8mV is ADC LSB */ 405/* Some of analog inputs have internal scaling (2x), 8mV is ADC LSB */