Sat Nov 26 03:19:42 2011 UTC ()
Move KASSERT down to the point where the endpoint is known to exist.


(joerg)
diff -r1.50 -r1.51 src/sys/dev/usb/umidi.c

cvs diff -r1.50 -r1.51 src/sys/dev/usb/umidi.c (expand / switch to unified diff)

--- src/sys/dev/usb/umidi.c 2011/11/26 03:14:25 1.50
+++ src/sys/dev/usb/umidi.c 2011/11/26 03:19:42 1.51
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: umidi.c,v 1.50 2011/11/26 03:14:25 joerg Exp $ */ 1/* $NetBSD: umidi.c,v 1.51 2011/11/26 03:19:42 joerg Exp $ */
2/* 2/*
3 * Copyright (c) 2001 The NetBSD Foundation, Inc. 3 * Copyright (c) 2001 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Takuya SHIOZAKI (tshiozak@NetBSD.org) and (full-size transfers, extended 7 * by Takuya SHIOZAKI (tshiozak@NetBSD.org) and (full-size transfers, extended
8 * hw_if) Chapman Flack (chap@NetBSD.org). 8 * hw_if) Chapman Flack (chap@NetBSD.org).
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.50 2011/11/26 03:14:25 joerg Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.51 2011/11/26 03:19:42 joerg Exp $");
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38#include <sys/kernel.h> 38#include <sys/kernel.h>
39#include <sys/malloc.h> 39#include <sys/malloc.h>
40#include <sys/device.h> 40#include <sys/device.h>
41#include <sys/ioctl.h> 41#include <sys/ioctl.h>
42#include <sys/conf.h> 42#include <sys/conf.h>
43#include <sys/file.h> 43#include <sys/file.h>
44#include <sys/select.h> 44#include <sys/select.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46#include <sys/vnode.h> 46#include <sys/vnode.h>
@@ -1138,31 +1138,31 @@ open_in_jack(struct umidi_jack *jack, vo @@ -1138,31 +1138,31 @@ open_in_jack(struct umidi_jack *jack, vo
1138 } 1138 }
1139 1139
1140 return err; 1140 return err;
1141} 1141}
1142 1142
1143static void 1143static void
1144close_out_jack(struct umidi_jack *jack) 1144close_out_jack(struct umidi_jack *jack)
1145{ 1145{
1146 struct umidi_endpoint *ep; 1146 struct umidi_endpoint *ep;
1147 struct umidi_softc *sc; 1147 struct umidi_softc *sc;
1148 u_int16_t mask; 1148 u_int16_t mask;
1149 int err; 1149 int err;
1150 1150
1151 KASSERT(mutex_owned(&ep->sc->sc_lock)); 
1152 1151
1153 if (jack->opened) { 1152 if (jack->opened) {
1154 ep = jack->endpoint; 1153 ep = jack->endpoint;
1155 sc = ep->sc; 1154 sc = ep->sc;
 1155 KASSERT(mutex_owned(&sc->sc_lock));
1156 mask = 1 << (jack->cable_number); 1156 mask = 1 << (jack->cable_number);
1157 while (mask & (ep->this_schedule | ep->next_schedule)) { 1157 while (mask & (ep->this_schedule | ep->next_schedule)) {
1158 err = cv_timedwait_sig(&sc->sc_cv, &sc->sc_lock, 1158 err = cv_timedwait_sig(&sc->sc_cv, &sc->sc_lock,
1159 mstohz(10)); 1159 mstohz(10));
1160 if (err) 1160 if (err)
1161 break; 1161 break;
1162 } 1162 }
1163 jack->opened = 0; 1163 jack->opened = 0;
1164 jack->endpoint->num_open--; 1164 jack->endpoint->num_open--;
1165 ep->this_schedule &= ~mask; 1165 ep->this_schedule &= ~mask;
1166 ep->next_schedule &= ~mask; 1166 ep->next_schedule &= ~mask;
1167 } 1167 }
1168} 1168}