Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Convert ltsleep() in atppc(4) to modern interfaces.



details:   https://anonhg.NetBSD.org/src/rev/874485bf77f7
branches:  trunk
changeset: 765419:874485bf77f7
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Thu May 26 02:29:23 2011 +0000

description:
Convert ltsleep() in atppc(4) to modern interfaces.

Reviewed by rmind@.

diffstat:

 sys/dev/ic/atppc.c      |  140 +++++++++++++++++------------------------------
 sys/dev/ic/atppcvar.h   |   33 ++--------
 sys/dev/isa/atppc_isa.c |    6 +-
 3 files changed, 62 insertions(+), 117 deletions(-)

diffs (truncated from 572 to 300 lines):

diff -r e6ab96e73ae4 -r 874485bf77f7 sys/dev/ic/atppc.c
--- a/sys/dev/ic/atppc.c        Thu May 26 00:44:14 2011 +0000
+++ b/sys/dev/ic/atppc.c        Thu May 26 02:29:23 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc.c,v 1.28 2008/12/16 22:35:30 christos Exp $ */
+/* $NetBSD: atppc.c,v 1.29 2011/05/26 02:29:23 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atppc.c,v 1.28 2008/12/16 22:35:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc.c,v 1.29 2011/05/26 02:29:23 jakllsch Exp $");
 
 #include "opt_atppc.h"
 
@@ -131,7 +131,7 @@
 /* Miscellaneous */
 static int atppc_poll_str(const struct atppc_softc * const, const u_int8_t,
        const u_int8_t);
-static int atppc_wait_interrupt(struct atppc_softc * const, const void *,
+static int atppc_wait_interrupt(struct atppc_softc * const, kcondvar_t *,
        const u_int8_t);
 
 
@@ -148,7 +148,9 @@
        struct parport_adapter sc_parport_adapter;
        char buf[64];
 
-       ATPPC_LOCK_INIT(lsc);
+       mutex_init(&lsc->sc_lock, MUTEX_DEFAULT, IPL_TTY);
+       cv_init(&lsc->sc_out_cv, "atppcout");
+       cv_init(&lsc->sc_in_cv, "atppcin");
 
        /* Probe and set up chipset */
        if (atppc_detect_chipset(lsc) != 0) {
@@ -181,11 +183,6 @@
                        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 */
@@ -616,6 +613,8 @@
        int claim = 1;
        enum { NONE, READER, WRITER } wake_up = NONE;
 
+       mutex_enter(&atppc->sc_lock);
+
        /* Record registers' status */
        atppc->sc_str_intr = atppc_r_str(atppc);
        atppc->sc_ctr_intr = atppc_r_ctr(atppc);
@@ -706,11 +705,11 @@
                        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;
                }
        }
@@ -724,6 +723,8 @@
                }
        }
 
+       mutex_exit(&atppc->sc_lock);
+
        return claim;
 }
 
@@ -736,18 +737,15 @@
 atppc_check_epp_timeout(device_t dev)
 {
        struct atppc_softc *atppc = device_private(dev);
-       int s;
        int error;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        atppc_reset_epp_timeout(dev);
        error = !(atppc_r_str(atppc) & TIMEOUT);
        atppc_barrier_r(atppc);
 
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return (error);
 }
@@ -783,10 +781,8 @@
 {
        struct atppc_softc *atppc = device_private(dev);
        int error = 0;
-       int s;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        *cnt = 0;
 
@@ -835,8 +831,7 @@
        if (!(error))
                error = atppc->sc_inerr;
 
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return (error);
 }
@@ -847,12 +842,10 @@
 {
        struct atppc_softc * const atppc = device_private(dev);
        int error = 0;
-       int s;
 
        *cnt = 0;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        /* Set up line buffer */
        atppc->sc_outb = atppc->sc_outbstart = buf;
@@ -896,8 +889,7 @@
        if (!(error))
                error = atppc->sc_outerr;
 
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return (error);
 }
@@ -919,11 +911,9 @@
        struct atppc_softc *atppc = device_private(dev);
        u_int8_t ecr;
        u_int8_t chipset_mode;
-       int s;
        int rval = 0;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        /* If ECP capable, configure ecr register */
        if (atppc->sc_has & ATPPC_HAS_ECP) {
@@ -1040,8 +1030,7 @@
        }
 
 end:
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return rval;
 }
@@ -1052,10 +1041,8 @@
 {
        struct atppc_softc *atppc = device_private(dev);
        int mode;
-       int s;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        /* The chipset can only be in one mode at a time logically */
        switch (atppc->sc_mode) {
@@ -1089,8 +1076,7 @@
                break;
        }
 
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return mode;
 }
@@ -1102,11 +1088,9 @@
 {
        struct atppc_softc *atppc = device_private(dev);
        int i;
-       int s;
        u_int8_t r;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        /*
         * Only wait for FIFO to empty if mode is chipset is ECP-capable AND
@@ -1134,8 +1118,7 @@
                device_xname(dev)));
 
 end:
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return;
 }
@@ -1149,15 +1132,13 @@
        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 = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
 /* microsequence registers are equivalent to PC-like port registers */
 
@@ -1318,8 +1299,7 @@
                         */
                        if ((error = mi->arg[0].f(mi->arg[1].p,
                                atppc->sc_ptr))) {
-                               ATPPC_UNLOCK(atppc);
-                               splx(s);
+                               mutex_exit(&atppc->sc_lock);
                                return (error);
                        }
                        mi++;
@@ -1373,8 +1353,7 @@
                        /* update pc for atppc level of execution */
                        *p_msq = mi;
 
-                       ATPPC_UNLOCK(atppc);
-                       splx(s);
+                       mutex_exit(&atppc->sc_lock);
                        return (0);
                        break;
 
@@ -1397,10 +1376,8 @@
 {
        struct atppc_softc *atppc = device_private(dev);
        u_int8_t val = 0;
-       int s;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        switch (iop) {
        case PPBUS_OUTSB_EPP:
@@ -1477,8 +1454,7 @@
 
        atppc_barrier(atppc);
 
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return val;
 }
@@ -1489,10 +1465,8 @@
 {
        struct atppc_softc *atppc = device_private(dev);
        int rval = 0;
-       int s;
 
-       s = splatppc();
-       ATPPC_LOCK(atppc);
+       mutex_enter(&atppc->sc_lock);
 
        switch(index) {
        case PPBUS_IVAR_EPP_PROTO:
@@ -1515,8 +1489,7 @@
                rval = ENODEV;
        }
 
-       ATPPC_UNLOCK(atppc);
-       splx(s);
+       mutex_exit(&atppc->sc_lock);
 
        return rval;
 }
@@ -1527,10 +1500,8 @@
 {



Home | Main Index | Thread Index | Old Index