Skip to content

Commit

Permalink
hwmon: (w83627ehf) Fix negative 8-bit temperature values
Browse files Browse the repository at this point in the history
commit 133d324d82e144588939ad25b732b5b6c33b03d9 upstream.

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 bce26c5.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jean Delvare authored and gregkh committed Oct 25, 2011
1 parent 83643e5 commit 63e0101
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/hwmon/w83627ehf.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,16 @@ temp_from_reg(u16 reg, s16 regval)
{
if (is_word_sized(reg))
return LM75_TEMP_FROM_REG(regval);
return regval * 1000;
return ((s8)regval) * 1000;
}

static inline u16
temp_to_reg(u16 reg, long temp)
{
if (is_word_sized(reg))
return LM75_TEMP_TO_REG(temp);
return DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, -127000, 128000), 1000);
return (s8)DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, -127000, 128000),
1000);
}

/* Some of analog inputs have internal scaling (2x), 8mV is ADC LSB */
Expand Down

0 comments on commit 63e0101

Please sign in to comment.