Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sgimips/hpc Convert simple_lock/ltsleep to mutex/co...



details:   https://anonhg.NetBSD.org/src/rev/dd7be691384d
branches:  trunk
changeset: 765885:dd7be691384d
user:      rmind <rmind%NetBSD.org@localhost>
date:      Thu Jun 09 02:49:32 2011 +0000

description:
Convert simple_lock/ltsleep to mutex/condvar and malloc to kmem.

diffstat:

 sys/arch/sgimips/hpc/pi1ppc.c    |  150 +++++++++++---------------------------
 sys/arch/sgimips/hpc/pi1ppcvar.h |   37 ++-------
 2 files changed, 52 insertions(+), 135 deletions(-)

diffs (truncated from 557 to 300 lines):

diff -r c2f234bc2a27 -r dd7be691384d sys/arch/sgimips/hpc/pi1ppc.c
--- a/sys/arch/sgimips/hpc/pi1ppc.c     Wed Jun 08 23:05:48 2011 +0000
+++ b/sys/arch/sgimips/hpc/pi1ppc.c     Thu Jun 09 02:49:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pi1ppc.c,v 1.9 2011/02/16 23:44:20 jmcneill Exp $ */
+/* $NetBSD: pi1ppc.c,v 1.10 2011/06/09 02:49:32 rmind Exp $ */
 
 /*
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -33,19 +33,16 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pi1ppc.c,v 1.9 2011/02/16 23:44:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pi1ppc.c,v 1.10 2011/06/09 02:49:32 rmind Exp $");
 
 #include "opt_pi1ppc.h"
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
 #include <sys/systm.h>
-#include <sys/vnode.h>
-#include <sys/syslog.h>
 
 #include <machine/bus.h>
 /*#include <machine/intr.h>*/
@@ -74,7 +71,6 @@
 int pi1ppc_verbose = 1;
 #endif
 
-
 /* Prototypes for functions. */
 
 /* PC-style register emulation */
@@ -100,7 +96,6 @@
                                        0,4,BUS_SPACE_BARRIER_WRITE)
 #define        pi1ppc_barrier(_x)  pi1ppc_barrier_r(_x)
 
-
 /* Print function for config_found() */
 static int pi1ppc_print(void *, const char *);
 
@@ -139,7 +134,7 @@
 
 static int pi1ppc_poll_str(struct pi1ppc_softc * const, const uint8_t,
        const uint8_t);
-static int pi1ppc_wait_interrupt(struct pi1ppc_softc * const, const void *,
+static int pi1ppc_wait_interrupt(struct pi1ppc_softc * const, kcondvar_t *,
        const uint8_t);
 
 static int pi1ppc_poll_interrupt_stat(struct pi1ppc_softc * const, 
@@ -209,8 +204,6 @@
        struct parport_adapter sc_parport_adapter;
        char buf[64];
 
-       PI1PPC_LOCK_INIT(lsc);
-
        /* For a PC, this is where the installed chipset is probed.
         * We *know* what we have, no need to probe.
         */
@@ -219,7 +212,11 @@
 
        /* XXX Once we support Interrupts & DMA, update this */
        lsc->sc_has = PI1PPC_HAS_PS2;
-          
+
+       mutex_init(&lsc->sc_lock, MUTEX_DEFAULT, IPL_TTY);
+       cv_init(&lsc->sc_in_cv, "pi1ppcin");
+       cv_init(&lsc->sc_out_cv, "pi1ppcou");
+
         /* Print out chipset capabilities */
        snprintb(buf, sizeof(buf), "\20\1INTR\2DMA\3FIFO\4PS2\5ECP\6EPP",
            lsc->sc_has);
@@ -233,14 +230,9 @@
        /* Last configuration step: set mode to standard mode */
        if (pi1ppc_setmode(lsc->sc_dev, PPBUS_COMPATIBLE) != 0) {
                PI1PPC_DPRINTF(("%s: unable to initialize mode.\n",
-                                device_xname(lsc->sc_dev)));
+                   device_xname(lsc->sc_dev)));
        }
 
-#if defined (MULTIPROCESSOR) || defined (LOCKDEBUG)
-       /* Initialize lock structure */
-       simple_lock_init(&(lsc->sc_lock));
-#endif
-
        /* Set up parport_adapter structure */
 
        /* Set capabilites */
@@ -311,10 +303,12 @@
                        printf("continuing (DETACH_FORCE)\n");
                }
        }
-
        if (!(flag & DETACH_QUIET))
                printf("%s detached", device_xname(dev));
 
+       mutex_destroy(&lsc->sc_lock);
+       cv_destroy(&lsc->sc_in_cv);
+       cv_destroy(&lsc->sc_out_cv);
        return 0;
 }
 
@@ -341,9 +335,7 @@
        struct pi1ppc_softc *pi1ppc = device_private(dev);
        int claim = 1;
        enum { NONE, READER, WRITER } wake_up = NONE;
-       int s;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        /* Record registers' status */
@@ -435,17 +427,15 @@
                        break;
 
                case READER:
-                       wakeup(atppc->sc_inb);
+                       cv_broadcast(atppc->sc_in_cv);
                        break;
 
                case WRITER:
-                       wakeup(atppc->sc_outb);
+                       cv_broadcast(atppc->sc_out_cv);
                        break;
                }
        }
 
-       PI1PPC_UNLOCK(atppc);
-
        /* Call all of the installed handlers */
        if (claim) {
                struct atppc_handler_node * callback;
@@ -454,8 +444,7 @@
                                (*callback->func)(callback->arg);
                }
        }
-
-       splx(s);
+       PI1PPC_UNLOCK(atppc);
 
        return claim;
 #else
@@ -478,9 +467,7 @@
 {
        struct pi1ppc_softc *pi1ppc = device_private(dev);
        int error = 0;
-       int s;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        *cnt = 0;
@@ -522,7 +509,6 @@
                error = pi1ppc->sc_inerr;
 
        PI1PPC_UNLOCK(pi1ppc);
-       splx(s);
 
        return (error);
 }
@@ -533,11 +519,9 @@
 {
        struct pi1ppc_softc * const pi1ppc = device_private(dev);
        int error = 0;
-       int s;
 
        *cnt = 0;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        /* Set up line buffer */
@@ -574,7 +558,6 @@
                error = pi1ppc->sc_outerr;
 
        PI1PPC_UNLOCK(pi1ppc);
-       splx(s);
 
        return (error);
 }
@@ -596,10 +579,8 @@
        struct pi1ppc_softc *pi1ppc = device_private(dev);
        uint8_t ecr;
        uint8_t chipset_mode;
-       int s;
        int rval = 0;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        switch (mode) {
@@ -641,7 +622,6 @@
 
 end:
        PI1PPC_UNLOCK(pi1ppc);
-       splx(s);
 
        return rval;
 }
@@ -652,9 +632,7 @@
 {
        struct pi1ppc_softc *pi1ppc = device_private(dev);
        int mode;
-       int s;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        /* The chipset can only be in one mode at a time logically */
@@ -678,7 +656,6 @@
        }
 
        PI1PPC_UNLOCK(pi1ppc);
-       splx(s);
 
        return mode;
 }
@@ -784,14 +761,12 @@
        char cc, *p;
        int i, iter, len;
        int error;
-       int s;
        register int reg;
        register unsigned char mask;
        register int accum = 0;
        register char *ptr = NULL;
        struct ppbus_microseq *stack = NULL;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        /* Loop until microsequence execution finishes (ending op code) */
@@ -877,8 +852,7 @@
 
                case MS_OP_ADELAY:
                        if (mi->arg[0].i) {
-                               tsleep(pi1ppc, PPBUSPRI, "pi1ppcdelay",
-                                       mi->arg[0].i * (hz/1000));
+                               DELAY(mi->arg[0].i * 1000);
                        }
                        mi++;
                        break;
@@ -947,7 +921,6 @@
                        if ((error = mi->arg[0].f(mi->arg[1].p,
                                pi1ppc->sc_ptr))) {
                                PI1PPC_UNLOCK(pi1ppc);
-                               splx(s);
                                return (error);
                        }
                        mi++;
@@ -1002,9 +975,7 @@
                        *p_msq = mi;
 
                        PI1PPC_UNLOCK(pi1ppc);
-                       splx(s);
                        return (0);
-                       break;
 
                default:
                        panic("%s: unknown microsequence "
@@ -1025,9 +996,7 @@
 {
        struct pi1ppc_softc *pi1ppc = device_private(dev);
        uint8_t val = 0;
-       int s;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        switch (iop) {
@@ -1058,7 +1027,6 @@
        pi1ppc_barrier(pi1ppc);
 
        PI1PPC_UNLOCK(pi1ppc);
-       splx(s);
 
        return val;
 }
@@ -1069,9 +1037,7 @@
 {
        struct pi1ppc_softc *pi1ppc = device_private(dev);
        int rval = 0;
-       int s;
 
-       s = splpi1ppc();
        PI1PPC_LOCK(pi1ppc);
 
        switch(index) {
@@ -1088,8 +1054,6 @@
        }
 
        PI1PPC_UNLOCK(pi1ppc);
-       splx(s);
-



Home | Main Index | Thread Index | Old Index