]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
hwmon: (tmp421) Fix temperature conversions
authorJean Delvare <khali@linux-fr.org>
Fri, 5 Mar 2010 21:17:25 +0000 (22:17 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 15 Mar 2010 15:49:57 +0000 (08:49 -0700)
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>
drivers/hwmon/tmp421.c

index 20924343431b65f61048ca2fc05c5b1d93afbcd7..7b974c8033549d42f1d13181e701034b2b0dc36a 100644 (file)
@@ -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;