aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/tmp421.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-03-05 16:17:25 -0500
committerJean Delvare <khali@linux-fr.org>2010-03-05 16:17:25 -0500
commita44908d742a577fb5ccb9a8c082326d4cea234c2 (patch)
tree098a62ddb96853c7e66fb58b67f5f163b8d3d401 /drivers/hwmon/tmp421.c
parent8d59582a867470a3e0c3eced4a01625ae8dc546b (diff)
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
Diffstat (limited to 'drivers/hwmon/tmp421.c')
-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 a97e299b233b..bb9760d7e8b6 100644
--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -80,14 +80,16 @@ struct tmp421_data {
80 80
81static int temp_from_s16(s16 reg) 81static int temp_from_s16(s16 reg)
82{ 82{
83 int temp = reg; 83 /* Mask out status bits */
84 int temp = reg & ~0xf;
84 85
85 return (temp * 1000 + 128) / 256; 86 return (temp * 1000 + 128) / 256;
86} 87}
87 88
88static int temp_from_u16(u16 reg) 89static int temp_from_u16(u16 reg)
89{ 90{
90 int temp = reg; 91 /* Mask out status bits */
92 int temp = reg & ~0xf;
91 93
92 /* Add offset for extended temperature range. */ 94 /* Add offset for extended temperature range. */
93 temp -= 64 * 256; 95 temp -= 64 * 256;