Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dkwedge dk(4): Factor common mutex_exit out of branc...



details:   https://anonhg.NetBSD.org/src/rev/32ae27234e4b
branches:  trunk
changeset: 369569:32ae27234e4b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 22 00:19:33 2022 +0000

description:
dk(4): Factor common mutex_exit out of branches to keep it balanced.

No functional change intended.

diffstat:

 sys/dev/dkwedge/dk.c |  20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diffs (57 lines):

diff -r 0848c9aebaea -r 32ae27234e4b sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Mon Aug 22 00:19:22 2022 +0000
+++ b/sys/dev/dkwedge/dk.c      Mon Aug 22 00:19:33 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.114 2022/08/22 00:19:22 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.115 2022/08/22 00:19:33 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.114 2022/08/22 00:19:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.115 2022/08/22 00:19:33 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -581,18 +581,16 @@
 
        rc = 0;
        mutex_enter(&dk->dk_openlock);
-       if (dk->dk_openmask == 0)
+       if (dk->dk_openmask == 0) {
                /* nothing to do */
-               mutex_exit(&dk->dk_openlock);
-       else if ((flags & DETACH_FORCE) == 0) {
+       } else if ((flags & DETACH_FORCE) == 0) {
                rc = EBUSY;
-               mutex_exit(&dk->dk_openlock);
        }  else {
                mutex_enter(&sc->sc_parent->dk_rawlock);
                rc = dklastclose(sc);
                mutex_exit(&sc->sc_parent->dk_rawlock);
-               mutex_exit(&sc->sc_dk.dk_openlock);
        }
+       mutex_exit(&sc->sc_dk.dk_openlock);
 
        return rc;
 }
@@ -1259,13 +1257,11 @@
 
        if (sc->sc_dk.dk_openmask == 0) {
                error = dklastclose(sc);
-               mutex_exit(&sc->sc_parent->dk_rawlock);
-               mutex_exit(&sc->sc_dk.dk_openlock);
-       } else {
-               mutex_exit(&sc->sc_parent->dk_rawlock);
-               mutex_exit(&sc->sc_dk.dk_openlock);
        }
 
+       mutex_exit(&sc->sc_parent->dk_rawlock);
+       mutex_exit(&sc->sc_dk.dk_openlock);
+
        return (error);
 }
 



Home | Main Index | Thread Index | Old Index