diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-01-26 22:07:15 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-01-26 22:07:15 +0000 |
commit | 2ae7f10106652c83326282cc4ebdd367931919bb (patch) | |
tree | 02009905698685e62b5877473aad7e1882b8fa8a /sys | |
parent | c8f5fa24f30170186fc9af2f82f22737a9166d19 (diff) |
Make lm at iic detach properly, and use config_detach(9) to fully detach
lm at iic if we attach lm at isa for the same chip.
tested by robert@, krw@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/i2c/lm_i2c.c | 14 | ||||
-rw-r--r-- | sys/dev/ic/lm78.c | 16 | ||||
-rw-r--r-- | sys/dev/ic/lm78var.h | 3 | ||||
-rw-r--r-- | sys/dev/isa/lm_isa.c | 11 |
4 files changed, 33 insertions, 11 deletions
diff --git a/sys/dev/i2c/lm_i2c.c b/sys/dev/i2c/lm_i2c.c index 62e838e3701..1854724ee67 100644 --- a/sys/dev/i2c/lm_i2c.c +++ b/sys/dev/i2c/lm_i2c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm_i2c.c,v 1.9 2006/01/17 22:02:51 kettenis Exp $ */ +/* $OpenBSD: lm_i2c.c,v 1.10 2006/01/26 22:07:14 kettenis Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -34,11 +34,13 @@ struct lm_i2c_softc { int lm_i2c_match(struct device *, void *, void *); void lm_i2c_attach(struct device *, struct device *, void *); +int lm_i2c_detach(struct device *, int); u_int8_t lm_i2c_readreg(struct lm_softc *, int); void lm_i2c_writereg(struct lm_softc *, int, int); struct cfattach lm_i2c_ca = { - sizeof(struct lm_i2c_softc), lm_i2c_match, lm_i2c_attach + sizeof(struct lm_i2c_softc), lm_i2c_match, + lm_i2c_attach, lm_i2c_detach }; int @@ -96,6 +98,14 @@ lm_i2c_attach(struct device *parent, struct device *self, void *aux) iic_ignore_addr(0x48 + ((data >> 4) & 0x7)); } +int +lm_i2c_detach(struct device *self, int flags) +{ + struct lm_i2c_softc *sc = (struct lm_i2c_softc *)self; + + return lm_detach(&sc->sc_lmsc); +} + u_int8_t lm_i2c_readreg(struct lm_softc *lmsc, int reg) { diff --git a/sys/dev/ic/lm78.c b/sys/dev/ic/lm78.c index aaf53d15f46..b1733a3b154 100644 --- a/sys/dev/ic/lm78.c +++ b/sys/dev/ic/lm78.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78.c,v 1.5 2006/01/19 22:20:35 kettenis Exp $ */ +/* $OpenBSD: lm78.c,v 1.6 2006/01/26 22:07:14 kettenis Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -337,6 +337,20 @@ lm_attach(struct lm_softc *sc) } int +lm_detach(struct lm_softc *sc) +{ + int i; + + /* Remove sensors */ + for (i = 0; i < sc->numsensors; i++) + sensor_del(&sc->sensors[i]); + + sensor_task_unregister(sc); + + return 0; +} + +int lm_match(struct lm_softc *sc) { int chipid; diff --git a/sys/dev/ic/lm78var.h b/sys/dev/ic/lm78var.h index ab6f9cd4ae0..16507de7161 100644 --- a/sys/dev/ic/lm78var.h +++ b/sys/dev/ic/lm78var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78var.h,v 1.4 2006/01/17 22:01:48 kettenis Exp $ */ +/* $OpenBSD: lm78var.h,v 1.5 2006/01/26 22:07:14 kettenis Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -143,3 +143,4 @@ struct lm_softc { }; void lm_attach(struct lm_softc *); +int lm_detach(struct lm_softc *); diff --git a/sys/dev/isa/lm_isa.c b/sys/dev/isa/lm_isa.c index a26eec646cd..3499be4051a 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.9 2006/01/23 18:45:33 kettenis Exp $ */ +/* $OpenBSD: lm_isa.c,v 1.10 2006/01/26 22:07:14 kettenis Exp $ */ /* $NetBSD: lm_isa.c,v 1.9 2002/11/15 14:55:44 ad Exp $ */ /*- @@ -157,7 +157,7 @@ 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; struct lm_softc *lmsc; - int iobase, i, j; + int iobase, i; u_int8_t sbusaddr; sc->sc_iot = ia->ia_iot; @@ -191,11 +191,8 @@ lm_isa_attach(struct device *parent, struct device *self, void *aux) 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; - } + lmsc->chipid == sc->sc_lmsc.chipid) + config_detach(&lmsc->sc_dev, 0); } } |