summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-03-05 22:17:25 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-15 08:49:57 -0700
commitbc6fb9e8ba0e5ec6641527b2cfdf170e332f6a5e (patch)
treed281ab84e5651c59b3746ae9bfebe8f6c8160c10 /drivers/hwmon
parent95c2a40e131872cef98d2ec9db1a7ced88da53b9 (diff)
hwmon: (tmp421) Fix temperature conversions
commit a44908d742a577fb5ccb9a8c082326d4cea234c2 upstream. The low bits of temperature registers are status bits, they must be masked out before converting the register values to temperatures. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Andre Prendel <andre.prendel@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/tmp421.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c
index 20924343431b..7b974c803354 100644
--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -81,14 +81,16 @@ struct tmp421_data {
static int temp_from_s16(s16 reg)
{
- int temp = reg;
+ /* Mask out status bits */
+ int temp = reg & ~0xf;
return (temp * 1000 + 128) / 256;
}
static int temp_from_u16(u16 reg)
{
- int temp = reg;
+ /* Mask out status bits */
+ int temp = reg & ~0xf;
/* Add offset for extended temperature range. */
temp -= 64 * 256;