diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-26 03:52:54 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-26 03:52:54 +0000 |
commit | 803b870d2e16c0449e12ef9d0f60ebe03327ee6e (patch) | |
tree | fe8592d3fdd3f776cd60fa8b623eec7238a83db9 | |
parent | 7a5acbb0d76e3d227cb53b7466cc47f179990f50 (diff) |
if start is already set, avoid setting it again
-rw-r--r-- | sys/dev/i2c/lm87.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/dev/i2c/lm87.c b/sys/dev/i2c/lm87.c index 40c2d44ce04..da429f527ec 100644 --- a/sys/dev/i2c/lm87.c +++ b/sys/dev/i2c/lm87.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm87.c,v 1.7 2005/11/16 23:30:28 kettenis Exp $ */ +/* $OpenBSD: lm87.c,v 1.8 2005/12/26 03:52:53 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -130,12 +130,14 @@ lmenv_attach(struct device *parent, struct device *self, void *aux) return; } - data |= LM87_CONFIG1_START; - if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, - sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) { - iic_release_bus(sc->sc_tag, 0); - printf(": cannot write Configuration Register 1\n"); - return; + if ((data & LM87_CONFIG1_START) == 0) { + data |= LM87_CONFIG1_START; + if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) { + iic_release_bus(sc->sc_tag, 0); + printf(": cannot write Configuration Register 1\n"); + return; + } } cmd = LM87_REVISION; |