diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2006-04-30 22:30:18 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2006-04-30 22:30:18 +0000 |
commit | 49d35399cf109e9c233874ce59d1ebc243dd92fd (patch) | |
tree | 1b4cb2e4ffee43a7374948f7e711e4f02ff063bc | |
parent | e6339341d40e6869a46412dcb7a5c65033dd46a7 (diff) |
incorporate feedback from kettenis@: fix init of sc_temp_invalid for LM90,
make sc_temp_invalid an array and set 0x7f as an invalid reading for the
Maxim 6690 too
-rw-r--r-- | sys/dev/i2c/maxim6690.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/sys/dev/i2c/maxim6690.c b/sys/dev/i2c/maxim6690.c index 238e32f9456..70abee2301b 100644 --- a/sys/dev/i2c/maxim6690.c +++ b/sys/dev/i2c/maxim6690.c @@ -1,4 +1,4 @@ -/* $OpenBSD: maxim6690.c,v 1.9 2006/04/30 09:33:19 djm Exp $ */ +/* $OpenBSD: maxim6690.c,v 1.10 2006/04/30 22:30:17 djm Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -33,8 +33,8 @@ #define MAX6690_REVISION 0xff /* absent on MAX6642 */ #define MAX6642_TEMP_INVALID 0xff /* sensor disconnected */ -#define MAX6657_TEMP_INVALID2 0x7f /* sensor disconnected */ #define MAX6690_TEMP_INVALID 0x80 /* sensor disconnected */ +#define MAX6690_TEMP_INVALID2 0x7f /* open-circuit without pull-up */ #define LM90_TEMP_INVALID 0x7f /* sensor disconnected */ #define MAX6642_TEMP2_MASK 0xc0 /* significant bits */ @@ -51,8 +51,7 @@ struct maxtmp_softc { i2c_tag_t sc_tag; i2c_addr_t sc_addr; - u_int8_t sc_temp_invalid; - u_int8_t sc_temp_invalid2; + u_int8_t sc_temp_invalid[2]; u_int8_t sc_temp2_mask; struct sensor sc_sensor[MAXTMP_NUM_SENSORS]; @@ -102,21 +101,19 @@ maxtmp_attach(struct device *parent, struct device *self, void *aux) sc->sc_addr = ia->ia_addr; if (strcmp(ia->ia_name, "max6642") == 0) { - sc->sc_temp_invalid = MAX6642_TEMP_INVALID; - sc->sc_temp_invalid2 = MAX6642_TEMP_INVALID; + sc->sc_temp_invalid[0] = MAX6642_TEMP_INVALID; + sc->sc_temp_invalid[1] = MAX6642_TEMP_INVALID; sc->sc_temp2_mask = MAX6642_TEMP2_MASK; - } else if (strcmp(ia->ia_name, "max6690") == 0) { - sc->sc_temp_invalid = MAX6690_TEMP_INVALID; - sc->sc_temp_invalid2 = MAX6690_TEMP_INVALID; - sc->sc_temp2_mask = MAX6690_TEMP2_MASK; - } else if (strcmp(ia->ia_name, "max6657") == 0 || + } else if (strcmp(ia->ia_name, "max6690") == 0 || + strcmp(ia->ia_name, "max6657") == 0 || strcmp(ia->ia_name, "max6658") == 0 || strcmp(ia->ia_name, "max6659") == 0) { - sc->sc_temp_invalid = MAX6690_TEMP_INVALID; - sc->sc_temp_invalid2 = MAX6657_TEMP_INVALID2; /* open circuit */ + sc->sc_temp_invalid[0] = MAX6690_TEMP_INVALID; + sc->sc_temp_invalid[1] = MAX6690_TEMP_INVALID2; sc->sc_temp2_mask = MAX6690_TEMP2_MASK; } else { - sc->sc_temp_invalid = LM90_TEMP_INVALID; + sc->sc_temp_invalid[0] = LM90_TEMP_INVALID; + sc->sc_temp_invalid[1] = LM90_TEMP_INVALID; sc->sc_temp2_mask = LM90_TEMP2_MASK; } printf(": %s", ia->ia_name); @@ -156,7 +153,7 @@ maxtmp_readport(struct maxtmp_softc *sc, u_int8_t cmd1, u_int8_t cmd2, if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, &cmd1, sizeof cmd1, &data, sizeof data, 0)) goto invalid; - if (data == sc->sc_temp_invalid || data == sc->sc_temp_invalid2) + if (data == sc->sc_temp_invalid[0] || data == sc->sc_temp_invalid[1]) goto invalid; if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, &cmd2, sizeof cmd2, &data2, sizeof data2, 0)) |