Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/usb No need to use mutex_obj_alloc here



details:   https://anonhg.NetBSD.org/src/rev/5f0261547ed0
branches:  nick-nhusb
changeset: 804519:5f0261547ed0
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Feb 06 07:59:26 2016 +0000

description:
No need to use mutex_obj_alloc here

diffstat:

 sys/dev/usb/ucom.c |  136 ++++++++++++++++++++++++++--------------------------
 1 files changed, 68 insertions(+), 68 deletions(-)

diffs (truncated from 487 to 300 lines):

diff -r 4f21c27d9a62 -r 5f0261547ed0 sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c        Sat Feb 06 07:53:11 2016 +0000
+++ b/sys/dev/usb/ucom.c        Sat Feb 06 07:59:26 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucom.c,v 1.108.2.11 2015/12/28 09:26:33 skrll Exp $    */
+/*     $NetBSD: ucom.c,v 1.108.2.12 2016/02/06 07:59:26 skrll Exp $    */
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.11 2015/12/28 09:26:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.12 2016/02/06 07:59:26 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -181,7 +181,7 @@
 
        krndsource_t            sc_rndsource;   /* random source */
 
-       kmutex_t                *sc_lock;
+       kmutex_t                sc_lock;
        kcondvar_t              sc_opencv;
        kcondvar_t              sc_detachcv;
 };
@@ -285,7 +285,7 @@
        sc->sc_dying = 0;
 
        sc->sc_si = softint_establish(SOFTINT_USB, ucom_softintr, sc);
-       sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTUSB);
+       mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
        cv_init(&sc->sc_opencv, "ucomopen");
        cv_init(&sc->sc_detachcv, "ucomdtch");
 
@@ -392,9 +392,9 @@
        DPRINTF("sc=%p flags=%d tp=%p", sc, flags, tp, 0);
        DPRINTF("... pipe=%d,%d",sc->sc_bulkin_no, sc->sc_bulkout_no, 0, 0);
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        sc->sc_dying = 1;
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        pmf_device_deregister(self);
 
@@ -403,7 +403,7 @@
        if (sc->sc_bulkout_pipe != NULL)
                usbd_abort_pipe(sc->sc_bulkout_pipe);
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        while (sc->sc_refcnt > 0) {
                /* Wake up anyone waiting */
                if (tp != NULL) {
@@ -414,11 +414,11 @@
                        mutex_spin_exit(&tty_lock);
                }
                /* Wait for processes to go away. */
-               usb_detach_wait(sc->sc_dev, &sc->sc_detachcv, sc->sc_lock);
+               usb_detach_wait(sc->sc_dev, &sc->sc_detachcv, &sc->sc_lock);
        }
 
        softint_disestablish(sc->sc_si);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        /* locate the major number */
        maj = cdevsw_lookup_major(&ucom_cdevsw);
@@ -460,7 +460,7 @@
        /* Detach the random source */
        rnd_detach_source(&sc->sc_rndsource);
 
-       mutex_destroy(sc->sc_lock);
+       mutex_destroy(&sc->sc_lock);
        cv_destroy(&sc->sc_opencv);
        cv_destroy(&sc->sc_detachcv);
 
@@ -478,9 +478,9 @@
 
        switch (act) {
        case DVACT_DEACTIVATE:
-               mutex_enter(sc->sc_lock);
+               mutex_enter(&sc->sc_lock);
                sc->sc_dying = 1;
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return 0;
        default:
                return EOPNOTSUPP;
@@ -494,7 +494,7 @@
 
        UCOMHIST_FUNC(); UCOMHIST_CALLED();
 
-       KASSERT(mutex_owned(sc->sc_lock));
+       KASSERT(mutex_owned(&sc->sc_lock));
        /*
         * Hang up if necessary.  Wait a bit, so the other side has time to
         * notice even if we immediately open the port again.
@@ -502,7 +502,7 @@
        if (ISSET(tp->t_cflag, HUPCL)) {
                ucom_dtr(sc, 0);
                /* XXX will only timeout */
-               (void) kpause(ttclos, false, hz, sc->sc_lock);
+               (void) kpause(ttclos, false, hz, &sc->sc_lock);
        }
 }
 
@@ -520,14 +520,14 @@
        if (sc == NULL)
                return ENXIO;
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (sc->sc_dying) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return EIO;
        }
 
        if (!device_is_active(sc->sc_dev)) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return ENXIO;
        }
 
@@ -536,7 +536,7 @@
        DPRINTF("unit=%d, tp=%p\n", unit, tp, 0, 0);
 
        if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return EBUSY;
        }
 
@@ -544,10 +544,10 @@
         * Do the following iff this is a first open.
         */
        while (sc->sc_opening) {
-               error = cv_wait_sig(&sc->sc_opencv, sc->sc_lock);
+               error = cv_wait_sig(&sc->sc_opencv, &sc->sc_lock);
 
                if (error) {
-                       mutex_exit(sc->sc_lock);
+                       mutex_exit(&sc->sc_lock);
                        return error;
                }
        }
@@ -566,7 +566,7 @@
                                ucom_cleanup(sc);
                                sc->sc_opening = 0;
                                cv_signal(&sc->sc_opencv);
-                               mutex_exit(sc->sc_lock);
+                               mutex_exit(&sc->sc_lock);
                                return error;
                        }
                }
@@ -626,7 +626,7 @@
        }
        sc->sc_opening = 0;
        cv_signal(&sc->sc_opencv);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        error = ttyopen(tp, UCOMDIALOUT(dev), ISSET(flag, O_NONBLOCK));
        if (error)
@@ -642,10 +642,10 @@
        usbd_abort_pipe(sc->sc_bulkin_pipe);
        usbd_abort_pipe(sc->sc_bulkout_pipe);
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        sc->sc_opening = 0;
        cv_signal(&sc->sc_opencv);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        return error;
 
@@ -677,7 +677,7 @@
        if (sc == NULL)
                return 0;
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        tp = sc->sc_tty;
 
        if (!ISSET(tp->t_state, TS_ISOPEN)) {
@@ -705,7 +705,7 @@
                usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv);
 
 out:
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        return 0;
 }
@@ -722,22 +722,22 @@
        if (sc == NULL)
                return EIO;
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (sc->sc_dying) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return EIO;
        }
 
        tp = sc->sc_tty;
 
        sc->sc_refcnt++;
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
        error = ((*tp->t_linesw->l_read)(tp, uio, flag));
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
 
        if (--sc->sc_refcnt < 0)
                usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        return error;
 }
@@ -752,21 +752,21 @@
        if (sc == NULL)
                return EIO;
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (sc->sc_dying) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return EIO;
        }
 
        tp = sc->sc_tty;
 
        sc->sc_refcnt++;
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
        error = ((*tp->t_linesw->l_write)(tp, uio, flag));
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (--sc->sc_refcnt < 0)
                usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        return error;
 }
@@ -782,20 +782,20 @@
        if (sc == NULL)
                return POLLHUP;
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (sc->sc_dying) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return POLLHUP;
        }
        tp = sc->sc_tty;
 
        sc->sc_refcnt++;
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
        revents = ((*tp->t_linesw->l_poll)(tp, events, l));
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (--sc->sc_refcnt < 0)
                usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
 
        return revents;
 }
@@ -817,9 +817,9 @@
        if (sc == NULL)
                return EIO;
 
-       mutex_enter(sc->sc_lock);
+       mutex_enter(&sc->sc_lock);
        if (sc->sc_dying) {
-               mutex_exit(sc->sc_lock);
+               mutex_exit(&sc->sc_lock);
                return EIO;
        }
 
@@ -827,7 +827,7 @@
        error = ucom_do_ioctl(sc, cmd, data, flag, l);
        if (--sc->sc_refcnt < 0)
                usb_detach_broadcast(sc->sc_dev, &sc->sc_detachcv);
-       mutex_exit(sc->sc_lock);
+       mutex_exit(&sc->sc_lock);
        return error;
 }



Home | Main Index | Thread Index | Old Index