Skip to contentSkip to conversation

hwmon: (tmp421) Fix temperature conversions

PATCH New Jean Delvare 1 participant 1 message Mar 4, 2010 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 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.

---
 drivers/hwmon/tmp421.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/tmp421.c +4 -2
@@ -80,14 +80,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;
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors