diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-07-26 18:43:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-07-26 18:43:37 +0000 |
commit | 062b0097478eaca2f34bf9b128b95a945310d7c8 (patch) | |
tree | 2ca9abaf85bab97314cf4561acb3e4d1a9cacc36 /sys | |
parent | e6fd3356ab661c4e7fecd8e64fb9e9fd29bd9001 (diff) |
Calling a detach function from an attach function is no longer legal (
see a recent subr_autoconf.c commit). To resolve this problem, mark the
other attachment dead, and clean it up when the first servicing timeout
gets run.
ok kettenis
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/i2c/lm78_i2c.c | 14 | ||||
-rw-r--r-- | sys/dev/ic/lm78.c | 32 | ||||
-rw-r--r-- | sys/dev/ic/lm78var.h | 6 | ||||
-rw-r--r-- | sys/dev/isa/lm78_isa.c | 4 |
4 files changed, 23 insertions, 33 deletions
diff --git a/sys/dev/i2c/lm78_i2c.c b/sys/dev/i2c/lm78_i2c.c index 8f0f7bdfc6f..b8074b4d1cc 100644 --- a/sys/dev/i2c/lm78_i2c.c +++ b/sys/dev/i2c/lm78_i2c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78_i2c.c,v 1.2 2008/11/03 00:17:47 cnst Exp $ */ +/* $OpenBSD: lm78_i2c.c,v 1.3 2011/07/26 18:43:36 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -34,13 +34,11 @@ 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, lm_i2c_detach + sizeof(struct lm_i2c_softc), lm_i2c_match, lm_i2c_attach }; int @@ -99,14 +97,6 @@ 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 80911066fcd..0a84be19fc6 100644 --- a/sys/dev/ic/lm78.c +++ b/sys/dev/ic/lm78.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78.c,v 1.20 2007/06/25 22:50:18 cnst Exp $ */ +/* $OpenBSD: lm78.c,v 1.21 2011/07/26 18:43:35 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -417,22 +417,6 @@ lm_attach(struct lm_softc *sc) } int -lm_detach(struct lm_softc *sc) -{ - int i; - - /* Remove sensors */ - sensordev_deinstall(&sc->sensordev); - for (i = 0; i < sc->numsensors; i++) - sensor_detach(&sc->sensordev, &sc->sensors[i]); - - if (sc->sensortask != NULL) - sensor_task_unregister(sc->sensortask); - - return 0; -} - -int lm_match(struct lm_softc *sc) { int chipid; @@ -599,6 +583,20 @@ lm_refresh(void *arg) { struct lm_softc *sc = arg; + if (sc->flags & LM78_DEAD) { + /* Remove sensors */ + int i; + + printf("%s: disabling sensors\n", sc->sc_dev.dv_xname); + sensordev_deinstall(&sc->sensordev); + for (i = 0; i < sc->numsensors; i++) + sensor_detach(&sc->sensordev, &sc->sensors[i]); + if (sc->sensortask != NULL) + sensor_task_unregister(sc->sensortask); + sc->sensortask = NULL; + return; + } + sc->refresh_sensor_data(sc); } diff --git a/sys/dev/ic/lm78var.h b/sys/dev/ic/lm78var.h index d664e3b0754..8566ffe4a1e 100644 --- a/sys/dev/ic/lm78var.h +++ b/sys/dev/ic/lm78var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78var.h,v 1.14 2007/06/25 22:50:18 cnst Exp $ */ +/* $OpenBSD: lm78var.h,v 1.15 2011/07/26 18:43:35 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -152,7 +152,9 @@ struct lm_softc { u_int8_t sbusaddr; u_int8_t chipid; u_int8_t vrm9; + +#define LM78_DEAD 1 + int flags; }; void lm_attach(struct lm_softc *); -int lm_detach(struct lm_softc *); diff --git a/sys/dev/isa/lm78_isa.c b/sys/dev/isa/lm78_isa.c index 648890d28f3..45093c8cc13 100644 --- a/sys/dev/isa/lm78_isa.c +++ b/sys/dev/isa/lm78_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78_isa.c,v 1.4 2008/02/17 15:04:08 kettenis Exp $ */ +/* $OpenBSD: lm78_isa.c,v 1.5 2011/07/26 18:43:36 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -177,7 +177,7 @@ lm_isa_attach(struct device *parent, struct device *self, void *aux) continue; if (lmsc && lmsc->sbusaddr == sbusaddr && lmsc->chipid == sc->sc_lmsc.chipid) - config_detach(&lmsc->sc_dev, 0); + lmsc->flags = LM78_DEAD; } } |