Przeglądaj źródła

hwmon: (tmp421) Fix temperature conversions

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>
Cc: stable@kernel.org
Jean Delvare 15 lat temu
rodzic
commit
a44908d742
1 zmienionych plików z 4 dodań i 2 usunięć
  1. 4 2
      drivers/hwmon/tmp421.c

+ 4 - 2
drivers/hwmon/tmp421.c

@@ -80,14 +80,16 @@ struct tmp421_data {
 
 
 static int temp_from_s16(s16 reg)
 static int temp_from_s16(s16 reg)
 {
 {
-	int temp = reg;
+	/* Mask out status bits */
+	int temp = reg & ~0xf;
 
 
 	return (temp * 1000 + 128) / 256;
 	return (temp * 1000 + 128) / 256;
 }
 }
 
 
 static int temp_from_u16(u16 reg)
 static int temp_from_u16(u16 reg)
 {
 {
-	int temp = reg;
+	/* Mask out status bits */
+	int temp = reg & ~0xf;
 
 
 	/* Add offset for extended temperature range. */
 	/* Add offset for extended temperature range. */
 	temp -= 64 * 256;
 	temp -= 64 * 256;