mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
hwmon: (tmp421) Fix temperature conversions
commit a44908d742 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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
95c2a40e13
commit
bc6fb9e8ba
@@ -81,14 +81,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;
|
||||
|
||||
Reference in New Issue
Block a user