summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorConstantine A. Murenin <cnst@cvs.openbsd.org>2009-07-10 00:07:38 +0000
committerConstantine A. Murenin <cnst@cvs.openbsd.org>2009-07-10 00:07:38 +0000
commitfc3c5c0ef9e1177f11a321a74510b4558d24f0c6 (patch)
tree258510f2d27f0659dcbc0e251d79e89416216c62 /sys/dev/i2c
parent75859d3d37615a82995c00ab8555f76d2fcbcf8b (diff)
the temperature value is really a 13-bit 2's complement; ok deraadt
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/sdtemp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/dev/i2c/sdtemp.c b/sys/dev/i2c/sdtemp.c
index c56e6f4bcb7..f245001ac0a 100644
--- a/sys/dev/i2c/sdtemp.c
+++ b/sys/dev/i2c/sdtemp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdtemp.c,v 1.8 2009/07/10 00:03:06 cnst Exp $ */
+/* $OpenBSD: sdtemp.c,v 1.9 2009/07/10 00:07:37 cnst Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
@@ -25,7 +25,6 @@
/* JEDEC JC-42.4 registers */
#define JC_TEMP 0x05
-#define JC_TEMP_SIGN 0x1000
/* Sensors */
#define JCTEMP_TEMP 0
@@ -107,9 +106,9 @@ sdtemp_refresh(void *arg)
cmd = JC_TEMP;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
&cmd, sizeof cmd, &data, sizeof data, 0) == 0) {
- sdata = betoh16(data) & 0x0fff;
- if (betoh16(data) & JC_TEMP_SIGN)
- sdata = -sdata;
+ sdata = betoh16(data) & 0x1fff;
+ if (sdata & 0x1000)
+ sdata = -0x2000;
sc->sc_sensor[JCTEMP_TEMP].value =
273150000 + 62500 * sdata;
sc->sc_sensor[JCTEMP_TEMP].flags &= ~SENSOR_FINVALID;