diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-01-15 21:40:15 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-01-15 21:40:15 +0000 |
commit | fddd2ea453bc08280eb864b7b1d12971a179c40d (patch) | |
tree | ca2bd38aab8f6e3f183d8f1330a6251a2fd3b4a1 | |
parent | 4a811a0a3208ceef42d10eec3b9531b216023ffb (diff) |
If we attach an lm(4) to isa(4) that is already attached to iic(4), disable
the one attached to iic(4).
idea from deraadt@
-rw-r--r-- | sys/dev/isa/lm_isa.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/sys/dev/isa/lm_isa.c b/sys/dev/isa/lm_isa.c index f5da1a23882..e0085dc725a 100644 --- a/sys/dev/isa/lm_isa.c +++ b/sys/dev/isa/lm_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm_isa.c,v 1.6 2006/01/14 20:05:06 kettenis Exp $ */ +/* $OpenBSD: lm_isa.c,v 1.7 2006/01/15 21:40:14 kettenis Exp $ */ /* $NetBSD: lm_isa.c,v 1.9 2002/11/15 14:55:44 ad Exp $ */ /*- @@ -52,6 +52,8 @@ #define LMC_ADDR 0x05 #define LMC_DATA 0x06 +extern struct cfdriver lm_cd; + #if defined(LMDEBUG) #define DPRINTF(x) do { printf x; } while (0) #else @@ -136,7 +138,9 @@ lm_isa_attach(struct device *parent, struct device *self, void *aux) { struct lm_isa_softc *sc = (struct lm_isa_softc *)self; struct isa_attach_args *ia = aux; - int iobase; + struct lm_softc *lmsc; + int iobase, i, j; + u_int8_t sbusaddr; sc->sc_iot = ia->ia_iot; iobase = ia->ipa_io[0].base; @@ -150,6 +154,31 @@ lm_isa_attach(struct device *parent, struct device *self, void *aux) sc->sc_lmsc.lm_writereg = lm_isa_writereg; sc->sc_lmsc.lm_readreg = lm_isa_readreg; lm_attach(&sc->sc_lmsc); + + /* + * Most devices supported by this driver can attach to iic(4) + * as well. However, we prefer to attach them to isa(4) since + * that causes less overhead and is more reliable. We look + * through all previously attached devices, and if we find an + * identical chip at the same serial bus address, we stop + * updating its sensors and mark them as invalid. + */ + + sbusaddr = lm_isa_readreg(&sc->sc_lmsc, LM_SBUSADDR); + if (sbusaddr == 0) + return; + + for (i = 0; i < lm_cd.cd_ndevs; i++) { + lmsc = lm_cd.cd_devs[i]; + if (lmsc == &sc->sc_lmsc) + continue; + if (lmsc && lmsc->sbusaddr == sbusaddr && + lmsc->chipid == sc->sc_lmsc.chipid) { + sensor_task_unregister(lmsc); + for (j = 0; j < lmsc->numsensors; j++) + lmsc->sensors[j].flags = SENSOR_FINVALID; + } + } } u_int8_t |