Skip to content

Commit

Permalink
hwmon: (tmp421) Fix temperature conversions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jean Delvare committed Mar 5, 2010
1 parent 8d59582 commit a44908d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/hwmon/tmp421.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a44908d

Please sign in to comment.