lkml.org 
[lkml]   [2010]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 063/123] hwmon: (tmp421) Fix temperature conversions
2.6.33-stable review patch.  If anyone has any objections, please let me know.

-----------------

From: Jean Delvare <khali@linux-fr.org>

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 | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -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;



\
 
 \ /
  Last update: 2010-03-13 02:25    [W:0.422 / U:4.284 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site