Source-Changes-HG archive

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

[src/trunk]: src/sys/opencrypto simplify mutex_enter/exit(crypto_q_mtx), and ...



details:   https://anonhg.NetBSD.org/src/rev/e20d0ab8454d
branches:  trunk
changeset: 354706:e20d0ab8454d
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Jun 26 05:34:48 2017 +0000

description:
simplify mutex_enter/exit(crypto_q_mtx), and fix missing exit.

diffstat:

 sys/opencrypto/crypto.c |  24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diffs (87 lines):

diff -r 4f2639032340 -r e20d0ab8454d sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Mon Jun 26 04:22:46 2017 +0000
+++ b/sys/opencrypto/crypto.c   Mon Jun 26 05:34:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.90 2017/06/15 12:45:10 knakahara Exp $ */
+/*     $NetBSD: crypto.c,v 1.91 2017/06/26 05:34:48 knakahara Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $   */
 /*     $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
 
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.90 2017/06/15 12:45:10 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.91 2017/06/26 05:34:48 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -1117,8 +1117,8 @@
                 * to other drivers in cryptointr() later.
                 */
                TAILQ_INSERT_TAIL(&crp_q, crp, crp_next);
-               mutex_exit(&crypto_q_mtx);
-               return 0;
+               result = 0;
+               goto out;
        }
 
        if (cap->cc_qblocked != 0) {
@@ -1128,8 +1128,8 @@
                 * it unblocks and the swi thread gets kicked.
                 */
                TAILQ_INSERT_TAIL(&crp_q, crp, crp_next);
-               mutex_exit(&crypto_q_mtx);
-               return 0;
+               result = 0;
+               goto out;
        }
 
        /*
@@ -1159,6 +1159,7 @@
                result = 0;
        }
 
+out:
        mutex_exit(&crypto_q_mtx);
        return result;
 }
@@ -1186,8 +1187,8 @@
         */
        if (cap == NULL) {
                TAILQ_INSERT_TAIL(&crp_kq, krp, krp_next);
-               mutex_exit(&crypto_q_mtx);
-               return 0;
+               result = 0;
+               goto out;
        }
 
        if (cap->cc_kqblocked != 0) {
@@ -1197,8 +1198,8 @@
                 * it unblocks and the swi thread gets kicked.
                 */
                TAILQ_INSERT_TAIL(&crp_kq, krp, krp_next);
-               mutex_exit(&crypto_q_mtx);
-               return 0;
+               result = 0;
+               goto out;
        }
 
        crypto_driver_unlock(cap);
@@ -1214,7 +1215,6 @@
                crypto_driver_unlock(cap);
                TAILQ_INSERT_HEAD(&crp_kq, krp, krp_next);
                cryptostats.cs_kblocks++;
-               mutex_exit(&crypto_q_mtx);
 
                /*
                 * The krp is enqueued to crp_kq, that is,
@@ -1224,6 +1224,8 @@
                result = 0;
        }
 
+out:
+       mutex_exit(&crypto_q_mtx);
        return result;
 }
 



Home | Main Index | Thread Index | Old Index