diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-27 18:28:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-27 18:28:52 +0000 |
commit | 1728d3241352f3c138c9ba4ca3293d8875e4bf63 (patch) | |
tree | 712d26eeb61d682f95513b2794f6be29e7571698 /sys/dev/i2c/adm1021.c | |
parent | 4bbbc10fd4639be17d042362a32260e0b6cd7a26 (diff) |
only start, if not already started
Diffstat (limited to 'sys/dev/i2c/adm1021.c')
-rw-r--r-- | sys/dev/i2c/adm1021.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/dev/i2c/adm1021.c b/sys/dev/i2c/adm1021.c index dbdc467df71..c6ec208999b 100644 --- a/sys/dev/i2c/adm1021.c +++ b/sys/dev/i2c/adm1021.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1021.c,v 1.11 2005/12/27 17:18:18 deraadt Exp $ */ +/* $OpenBSD: adm1021.c,v 1.12 2005/12/27 18:28:51 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -93,16 +93,18 @@ admtemp_attach(struct device *parent, struct device *self, void *aux) if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) { iic_release_bus(sc->sc_tag, 0); - printf(": cannot get control register\n"); + printf(", cannot get control register\n"); return; } - data &= ~ADM1021_CONFIG_RUN; - cmd = ADM1021_CONFIG_WRITE; - if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, - sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) { - iic_release_bus(sc->sc_tag, 0); - printf(": cannot set control register\n"); - return; + if ((data & ADM1021_CONFIG_RUN) == 0) { + data &= ~ADM1021_CONFIG_RUN; + cmd = ADM1021_CONFIG_WRITE; + if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) { + iic_release_bus(sc->sc_tag, 0); + printf(", cannot set control register\n"); + return; + } } iic_release_bus(sc->sc_tag, 0); |