summaryrefslogtreecommitdiffstats
path: root/sys/dev/i2c/sdtemp.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2008-04-17 19:01:48 +0000
committerderaadt <deraadt@openbsd.org>2008-04-17 19:01:48 +0000
commit91eacc75c9904a072e8b7c3428f766321fd5fb57 (patch)
tree55ab09b9332dce463634e456f696c3177475a2e0 /sys/dev/i2c/sdtemp.c
parentdo not blindly call ieee80211_get_hdrlen() in rt2860_rx_intr(). (diff)
downloadwireguard-openbsd-91eacc75c9904a072e8b7c3428f766321fd5fb57.tar.xz
wireguard-openbsd-91eacc75c9904a072e8b7c3428f766321fd5fb57.zip
make it more apparent that when we are dealing with 16 bit registers
(not a series of 8 bit registers), the bytes come off the wire in big-endian order
Diffstat (limited to 'sys/dev/i2c/sdtemp.c')
-rw-r--r--sys/dev/i2c/sdtemp.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/dev/i2c/sdtemp.c b/sys/dev/i2c/sdtemp.c
index d2dde590fe2..ea83ec46dc5 100644
--- a/sys/dev/i2c/sdtemp.c
+++ b/sys/dev/i2c/sdtemp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdtemp.c,v 1.4 2008/04/10 17:14:09 deraadt Exp $ */
+/* $OpenBSD: sdtemp.c,v 1.5 2008/04/17 19:01:48 deraadt Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
@@ -100,22 +100,22 @@ void
sdtemp_refresh(void *arg)
{
struct sdtemp_softc *sc = arg;
- u_int8_t cmd, data[2];
- int16_t sdata;
+ u_int8_t cmd;
+ int16_t data, sdata;
iic_acquire_bus(sc->sc_tag, 0);
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 = ((data[0] << 8) | data[1]) & 0x0fff;
- if (data[0] & JC_TEMP_SIGN)
+ &cmd, sizeof cmd, &data, sizeof data, 0) == 0) {
+ sdata = betoh16(data) & 0x0fff;
+ if (betoh16(data) & JC_TEMP_SIGN)
sdata = -sdata;
sc->sc_sensor[JCTEMP_TEMP].value =
273150000 + 62500 * sdata;
sc->sc_sensor[JCTEMP_TEMP].flags &= ~SENSOR_FINVALID;
#if 0
- printf("sdtemp %02x%02x %04x %d\n", data[0], data[1],
+ printf("sdtemp %04x %04x %d\n", data & 0xffff,
(u_int)sdata & 0xffff,
sc->sc_sensor[JCTEMP_TEMP].value);
#endif