diff options
| author | 2009-07-10 00:07:37 +0000 | |
|---|---|---|
| committer | 2009-07-10 00:07:37 +0000 | |
| commit | 0ac637ad3990fc8977cf016819dc50cfe10c124d (patch) | |
| tree | 2e3662161c78d1b580e9f6ffe3e9f853b010f4f1 /sys/dev/i2c/sdtemp.c | |
| parent | fix the mask for the sign bit and some comment; ok deraadt (diff) | |
| download | wireguard-openbsd-0ac637ad3990fc8977cf016819dc50cfe10c124d.tar.xz wireguard-openbsd-0ac637ad3990fc8977cf016819dc50cfe10c124d.zip | |
the temperature value is really a 13-bit 2's complement; ok deraadt
Diffstat (limited to 'sys/dev/i2c/sdtemp.c')
| -rw-r--r-- | sys/dev/i2c/sdtemp.c | 9 |
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; |
