Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic simple_lock to mutex conversion.



details:   https://anonhg.NetBSD.org/src/rev/140b62b94fa0
branches:  trunk
changeset: 767825:140b62b94fa0
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sun Jul 31 18:39:00 2011 +0000

description:
simple_lock to mutex conversion.

diffstat:

 sys/dev/ic/ncr53c9x.c    |  56 ++++++++++++++++++++---------------------------
 sys/dev/ic/ncr53c9xvar.h |   6 ++--
 2 files changed, 27 insertions(+), 35 deletions(-)

diffs (222 lines):

diff -r fe23a1c61df2 -r 140b62b94fa0 sys/dev/ic/ncr53c9x.c
--- a/sys/dev/ic/ncr53c9x.c     Sun Jul 31 18:23:46 2011 +0000
+++ b/sys/dev/ic/ncr53c9x.c     Sun Jul 31 18:39:00 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ncr53c9x.c,v 1.142 2011/07/04 16:06:17 joerg Exp $     */
+/*     $NetBSD: ncr53c9x.c,v 1.143 2011/07/31 18:39:00 jakllsch Exp $  */
 
 /*-
  * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.142 2011/07/04 16:06:17 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.143 2011/07/31 18:39:00 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -194,7 +194,7 @@
        struct scsipi_adapter *adapt = &sc->sc_adapter;
        struct scsipi_channel *chan = &sc->sc_channel;
 
-       simple_lock_init(&sc->sc_lock);
+       mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_BIO);
 
        callout_init(&sc->sc_watchdog, 0);
 
@@ -341,6 +341,8 @@
        if (sc->sc_omess)
                free(sc->sc_omess, M_DEVBUF);
 
+       mutex_destroy(&sc->sc_lock);
+
        return 0;
 }
 
@@ -857,13 +859,12 @@
        struct scsipi_periph *periph;
        struct ncr53c9x_softc *sc;
        struct ncr53c9x_ecb *ecb;
-       int s, flags;
+       int flags;
 
        NCR_TRACE(("[ncr53c9x_scsipi_request] "));
 
        sc = device_private(chan->chan_adapter->adapt_dev);
-       s = splbio();
-       simple_lock(&sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
 
        switch (req) {
        case ADAPTER_REQ_RUN_XFER:
@@ -886,8 +887,7 @@
                        printf("%s: unable to allocate ecb\n",
                            device_xname(sc->sc_dev));
                        xs->error = XS_RESOURCE_SHORTAGE;
-                       simple_unlock(&sc->sc_lock);
-                       splx(s);
+                       mutex_exit(&sc->sc_lock);
                        scsipi_done(xs);
                        return;
                }
@@ -972,8 +972,7 @@
                break;
        }
 
-       simple_unlock(&sc->sc_lock);
-       splx(s);
+       mutex_exit(&sc->sc_lock);
 }
 
 void
@@ -1011,9 +1010,9 @@
        NCR_TRACE(("[ncr53c9x_poll] "));
        while (count) {
                if (NCRDMA_ISINTR(sc)) {
-                       simple_unlock(&sc->sc_lock);
+                       mutex_exit(&sc->sc_lock);
                        ncr53c9x_intr(sc);
-                       simple_lock(&sc->sc_lock);
+                       mutex_enter(&sc->sc_lock);
                }
 #if alternatively
                if (NCR_READ_REG(sc, NCR_STAT) & NCRSTAT_INT)
@@ -1036,16 +1035,14 @@
     int flag, struct proc *p)
 {
        struct ncr53c9x_softc *sc;
-       int s, error = 0;
+       int error = 0;
 
        sc = device_private(chan->chan_adapter->adapt_dev);
        switch (cmd) {
        case SCBUSIORESET:
-               s = splbio();
-               simple_lock(&sc->sc_lock);
+               mutex_enter(&sc->sc_lock);
                ncr53c9x_init(sc, 1);
-               simple_unlock(&sc->sc_lock);
-               splx(s);
+               mutex_exit(&sc->sc_lock);
                break;
        default:
                error = ENOTTY;
@@ -1279,9 +1276,9 @@
 
        ncr53c9x_free_ecb(sc, ecb);
        ti->cmds++;
-       simple_unlock(&sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
        scsipi_done(xs);
-       simple_lock(&sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
 }
 
 void
@@ -2090,7 +2087,7 @@
        if (!NCRDMA_ISINTR(sc))
                return 0;
 
-       simple_lock(&sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
 again:
        /* and what do the registers say... */
        ncr53c9x_readregs(sc);
@@ -2624,7 +2621,7 @@
                if (sc->sc_state == NCR_IDLE) {
                        printf("%s: stray interrupt\n",
                            device_xname(sc->sc_dev));
-                       simple_unlock(&sc->sc_lock);
+                       mutex_exit(&sc->sc_lock);
                        return 0;
                }
                break;
@@ -2815,7 +2812,7 @@
        }
 
 out:
-       simple_unlock(&sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
        return 1;
 
 reset:
@@ -2899,7 +2896,6 @@
        struct scsipi_periph *periph = xs->xs_periph;
        struct ncr53c9x_softc *sc;
        struct ncr53c9x_tinfo *ti;
-       int s;
 
        sc = device_private(periph->periph_channel->chan_adapter->adapt_dev);
        ti = &sc->sc_tinfo[periph->periph_target];
@@ -2919,8 +2915,7 @@
        printf("TRACE: %s.", ecb->trace);
 #endif
 
-       s = splbio();
-       simple_lock(&sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
 
        if (ecb->flags & ECB_ABORT) {
                /* abort timed out */
@@ -2946,8 +2941,7 @@
                }
        }
 
-       simple_unlock(&sc->sc_lock);
-       splx(s);
+       mutex_exit(&sc->sc_lock);
 }
 
 void
@@ -2956,12 +2950,11 @@
        struct ncr53c9x_softc *sc = arg;
        struct ncr53c9x_tinfo *ti;
        struct ncr53c9x_linfo *li;
-       int t, s;
+       int t;
        /* Delete any structures that have not been used in 10min. */
        time_t old = time_second - (10 * 60);
 
-       s = splbio();
-       simple_lock(&sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        for (t = 0; t < sc->sc_ntarg; t++) {
                ti = &sc->sc_tinfo[t];
                li = LIST_FIRST(&ti->luns);
@@ -2980,7 +2973,6 @@
                        li = LIST_NEXT(li, link);
                }
        }
-       simple_unlock(&sc->sc_lock);
-       splx(s);
+       mutex_exit(&sc->sc_lock);
        callout_reset(&sc->sc_watchdog, 60 * hz, ncr53c9x_watch, sc);
 }
diff -r fe23a1c61df2 -r 140b62b94fa0 sys/dev/ic/ncr53c9xvar.h
--- a/sys/dev/ic/ncr53c9xvar.h  Sun Jul 31 18:23:46 2011 +0000
+++ b/sys/dev/ic/ncr53c9xvar.h  Sun Jul 31 18:39:00 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ncr53c9xvar.h,v 1.54 2009/09/07 13:31:44 tsutsui Exp $ */
+/*     $NetBSD: ncr53c9xvar.h,v 1.55 2011/07/31 18:39:00 jakllsch Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 #ifndef _DEV_IC_NCR53C9XVAR_H_
 #define _DEV_IC_NCR53C9XVAR_H_
 
-#include <sys/simplelock.h>
+#include <sys/mutex.h>
 
 /* Set this to 1 for normal debug, or 2 for per-target tracing. */
 /* #define NCR53C9X_DEBUG              1 */
@@ -335,7 +335,7 @@
        int sc_minsync;         /* Minimum sync period / 4 */
        int sc_maxxfer;         /* Maximum transfer size */
 
-       struct simplelock sc_lock;/* driver mutex */
+       kmutex_t sc_lock;       /* driver mutex */
 };
 
 /* values for sc_state */



Home | Main Index | Thread Index | Old Index