From 6dfdfe57330946f5ed153ea2490bd8e9dc57bcd2 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Sun, 21 May 2006 03:10:50 +0000 Subject: replace lockmgr with rwlock. --- sys/scsi/safte.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c index 11cb1f20202..942767a6b79 100644 --- a/sys/scsi/safte.c +++ b/sys/scsi/safte.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safte.c,v 1.27 2006/05/09 05:51:54 deraadt Exp $ */ +/* $OpenBSD: safte.c,v 1.28 2006/05/21 03:10:49 dlg Exp $ */ /* * Copyright (c) 2005 David Gwynne @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ struct safte_sensor { struct safte_softc { struct device sc_dev; struct scsi_link *sc_link; - struct lock sc_lock; + struct rwlock sc_lock; u_int sc_encbuflen; u_char *sc_encbuf; @@ -162,7 +162,7 @@ safte_attach(struct device *parent, struct device *self, void *aux) sc->sc_link = sa->sa_sc_link; sa->sa_sc_link->device_softc = sc; - lockinit(&sc->sc_lock, PZERO, DEVNAME(sc), 0, 0); + rw_init(&sc->sc_lock, DEVNAME(sc)); printf("\n"); @@ -211,7 +211,7 @@ safte_detach(struct device *self, int flags) struct safte_softc *sc = (struct safte_softc *)self; int i; - lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL); + rw_enter_write(&sc->sc_lock); #if NBIO > 0 if (sc->sc_nslots > 0) @@ -232,8 +232,7 @@ safte_detach(struct device *self, int flags) if (sc->sc_encbuf != NULL) free(sc->sc_encbuf, M_DEVBUF); - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); - lockmgr(&sc->sc_lock, LK_DRAIN, NULL); + rw_exit_write(&sc->sc_lock); return (0); } @@ -383,7 +382,7 @@ safte_read_encstat(void *arg) struct safte_sensor *s; u_int16_t oot; - lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL); + rw_enter_write(&sc->sc_lock); memset(&cmd, 0, sizeof(cmd)); cmd.opcode = READ_BUFFER; @@ -401,7 +400,7 @@ safte_read_encstat(void *arg) if (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd, sizeof(cmd), sc->sc_encbuf, sc->sc_encbuflen, 2, 30000, NULL, flags) != 0) { - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); + rw_exit_write(&sc->sc_lock); return; } @@ -504,7 +503,7 @@ safte_read_encstat(void *arg) sc->sc_temps[i].se_sensor.status = (oot & (1 << i)) ? SENSOR_S_CRIT : SENSOR_S_OK; - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); + rw_exit_write(&sc->sc_lock); } #if NBIO > 0 @@ -547,12 +546,12 @@ safte_bio_blink(struct safte_softc *sc, struct bioc_blink *blink) return (EINVAL); } - lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL); + rw_enter_read(&sc->sc_lock); for (slot = 0; slot < sc->sc_nslots; slot++) { if (sc->sc_slots[slot] == blink->bb_target) break; } - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); + rw_exit_read(&sc->sc_lock); if (slot >= sc->sc_nslots) return (ENODEV); -- cgit v1.2.3