diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2006-10-01 11:43:41 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2006-10-01 11:43:41 +0000 |
commit | cc17f184cf399474424bf0557df8667729e0ae8d (patch) | |
tree | 1af8c1c40c60ee38f85d4e2838738e92f85d68bf /sys/dev | |
parent | e74736b544df96dbc776598af110eca43f82a3f0 (diff) |
Don't reuse bus lock for locking sensor task thread. Use a
separate lock.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/onewire/owtemp.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/sys/dev/onewire/owtemp.c b/sys/dev/onewire/owtemp.c index cdb7dcecc37..26ea09884c2 100644 --- a/sys/dev/onewire/owtemp.c +++ b/sys/dev/onewire/owtemp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: owtemp.c,v 1.3 2006/10/01 08:09:04 grange Exp $ */ +/* $OpenBSD: owtemp.c,v 1.4 2006/10/01 11:43:40 grange Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -25,6 +25,7 @@ #include <sys/device.h> #include <sys/kernel.h> #include <sys/proc.h> +#include <sys/rwlock.h> #include <sys/sensors.h> #include <dev/onewire/onewiredevs.h> @@ -41,8 +42,7 @@ struct owtemp_softc { u_int64_t sc_rom; struct sensor sc_sensor; - - int sc_dying; + struct rwlock sc_lock; }; int owtemp_match(struct device *, void *, void *); @@ -96,6 +96,7 @@ owtemp_attach(struct device *parent, struct device *self, void *aux) } sensor_add(&sc->sc_sensor); + rw_init(&sc->sc_lock, sc->sc_dev.dv_xname); printf("\n"); } @@ -104,11 +105,10 @@ owtemp_detach(struct device *self, int flags) { struct owtemp_softc *sc = (struct owtemp_softc *)self; + rw_enter_write(&sc->sc_lock); sensor_del(&sc->sc_sensor); - - onewire_lock(sc, 0); sensor_task_unregister(sc); - onewire_unlock(sc); + rw_exit_write(&sc->sc_lock); return (0); } @@ -116,16 +116,6 @@ owtemp_detach(struct device *self, int flags) int owtemp_activate(struct device *self, enum devact act) { - struct owtemp_softc *sc = (struct owtemp_softc *)self; - - switch (act) { - case DVACT_ACTIVATE: - break; - case DVACT_DEACTIVATE: - sc->sc_dying = 1; - break; - } - return (0); } @@ -135,6 +125,7 @@ owtemp_update(void *arg) struct owtemp_softc *sc = arg; u_int8_t data[9]; + rw_enter_write(&sc->sc_lock); onewire_lock(sc->sc_onewire, 0); if (onewire_reset(sc->sc_onewire) != 0) goto done; @@ -167,4 +158,5 @@ owtemp_update(void *arg) done: onewire_unlock(sc->sc_onewire); + rw_exit_write(&sc->sc_lock); } |