summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-08-12 17:13:31 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-08-12 17:13:31 +0000
commit33e8aee5ce106a59b7b8a0579848c69296642451 (patch)
tree8df502478952de22b1974f106ac2621c13d1275c /sys/dev/i2c
parent3c5fcedb64c93f83a5ebbd7c9051cdecf076b8f2 (diff)
Mark sensor as invalid if the i2c transaction to read its value fails.
ok deraadt@
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/ds1631.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/i2c/ds1631.c b/sys/dev/i2c/ds1631.c
index 946e2dc354c..4e18aeee5ed 100644
--- a/sys/dev/i2c/ds1631.c
+++ b/sys/dev/i2c/ds1631.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ds1631.c,v 1.10 2008/04/17 19:01:48 deraadt Exp $ */
+/* $OpenBSD: ds1631.c,v 1.11 2009/08/12 17:13:30 kettenis Exp $ */
/*
* Copyright (c) 2005 Theo de Raadt
@@ -143,9 +143,12 @@ maxds_refresh(void *arg)
cmd = DS1631_TEMP;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0) == 0)
+ sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0) == 0) {
sc->sc_sensor[MAXDS_TEMP].value = 273150000 +
(int)(betoh16(data)) / 8 * 31250;
+ sc->sc_sensor[MAXDS_TEMP].flags &= ~SENSOR_FINVALID;
+ } else
+ sc->sc_sensor[MAXDS_TEMP].flags |= SENSOR_FINVALID;
iic_release_bus(sc->sc_tag, 0);
}