From 33e8aee5ce106a59b7b8a0579848c69296642451 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 12 Aug 2009 17:13:31 +0000 Subject: Mark sensor as invalid if the i2c transaction to read its value fails. ok deraadt@ --- sys/dev/i2c/ds1631.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sys/dev/i2c') 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); } -- cgit v1.2.3