Tue Jan 22 14:01:20 2013 UTC ()
default pipe is mpsafe, deal with it


(jmcneill)
diff -r1.188 -r1.189 src/sys/dev/usb/usb_subr.c

cvs diff -r1.188 -r1.189 src/sys/dev/usb/usb_subr.c (expand / switch to unified diff)

--- src/sys/dev/usb/usb_subr.c 2013/01/22 12:40:43 1.188
+++ src/sys/dev/usb/usb_subr.c 2013/01/22 14:01:19 1.189
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usb_subr.c,v 1.188 2013/01/22 12:40:43 jmcneill Exp $ */ 1/* $NetBSD: usb_subr.c,v 1.189 2013/01/22 14:01:19 jmcneill Exp $ */
2/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at 9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology. 10 * Carlstedt Research & Technology.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.188 2013/01/22 12:40:43 jmcneill Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.189 2013/01/22 14:01:19 jmcneill Exp $");
36 36
37#ifdef _KERNEL_OPT 37#ifdef _KERNEL_OPT
38#include "opt_compat_netbsd.h" 38#include "opt_compat_netbsd.h"
39#include "opt_usbverbose.h" 39#include "opt_usbverbose.h"
40#endif 40#endif
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/systm.h> 43#include <sys/systm.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/malloc.h> 45#include <sys/malloc.h>
46#include <sys/device.h> 46#include <sys/device.h>
47#include <sys/select.h> 47#include <sys/select.h>
48#include <sys/proc.h> 48#include <sys/proc.h>
@@ -1161,28 +1161,28 @@ usbd_new_device(device_t parent, usbd_bu @@ -1161,28 +1161,28 @@ usbd_new_device(device_t parent, usbd_bu
1161 } 1161 }
1162 } 1162 }
1163 panic("usbd_new_device: cannot find HS port\n"); 1163 panic("usbd_new_device: cannot find HS port\n");
1164 found: 1164 found:
1165 DPRINTFN(1,("usbd_new_device: high speed port %d\n", p)); 1165 DPRINTFN(1,("usbd_new_device: high speed port %d\n", p));
1166 } else { 1166 } else {
1167 dev->myhsport = NULL; 1167 dev->myhsport = NULL;
1168 } 1168 }
1169 dev->speed = speed; 1169 dev->speed = speed;
1170 dev->langid = USBD_NOLANG; 1170 dev->langid = USBD_NOLANG;
1171 dev->cookie.cookie = ++usb_cookie_no; 1171 dev->cookie.cookie = ++usb_cookie_no;
1172 1172
1173 /* Establish the default pipe. */ 1173 /* Establish the default pipe. */
1174 err = usbd_setup_pipe(dev, 0, &dev->def_ep, USBD_DEFAULT_INTERVAL, 1174 err = usbd_setup_pipe_flags(dev, 0, &dev->def_ep, USBD_DEFAULT_INTERVAL,
1175 &dev->default_pipe); 1175 &dev->default_pipe, USBD_MPSAFE);
1176 if (err) { 1176 if (err) {
1177 usbd_remove_device(dev, up); 1177 usbd_remove_device(dev, up);
1178 return (err); 1178 return (err);
1179 } 1179 }
1180 1180
1181 dd = &dev->ddesc; 1181 dd = &dev->ddesc;
1182 /* Try a few times in case the device is slow (i.e. outside specs.) */ 1182 /* Try a few times in case the device is slow (i.e. outside specs.) */
1183 for (i = 0; i < 10; i++) { 1183 for (i = 0; i < 10; i++) {
1184 /* Get the first 8 bytes of the device descriptor. */ 1184 /* Get the first 8 bytes of the device descriptor. */
1185 err = usbd_get_initial_ddesc(dev, dd); 1185 err = usbd_get_initial_ddesc(dev, dd);
1186 if (!err) 1186 if (!err)
1187 break; 1187 break;
1188 usbd_delay_ms(dev, 200); 1188 usbd_delay_ms(dev, 200);
@@ -1249,28 +1249,28 @@ usbd_new_device(device_t parent, usbd_bu @@ -1249,28 +1249,28 @@ usbd_new_device(device_t parent, usbd_bu
1249 dev->address = addr; /* new device address now */ 1249 dev->address = addr; /* new device address now */
1250 bus->devices[addr] = dev; 1250 bus->devices[addr] = dev;
1251 1251
1252 err = usbd_reload_device_desc(dev); 1252 err = usbd_reload_device_desc(dev);
1253 if (err) { 1253 if (err) {
1254 DPRINTFN(-1, ("usbd_new_device: addr=%d, getting full desc " 1254 DPRINTFN(-1, ("usbd_new_device: addr=%d, getting full desc "
1255 "failed\n", addr)); 1255 "failed\n", addr));
1256 usbd_remove_device(dev, up); 1256 usbd_remove_device(dev, up);
1257 return (err); 1257 return (err);
1258 } 1258 }
1259 1259
1260 /* Re-establish the default pipe with the new address. */ 1260 /* Re-establish the default pipe with the new address. */
1261 usbd_kill_pipe(dev->default_pipe); 1261 usbd_kill_pipe(dev->default_pipe);
1262 err = usbd_setup_pipe(dev, 0, &dev->def_ep, USBD_DEFAULT_INTERVAL, 1262 err = usbd_setup_pipe_flags(dev, 0, &dev->def_ep, USBD_DEFAULT_INTERVAL,
1263 &dev->default_pipe); 1263 &dev->default_pipe, USBD_MPSAFE);
1264 if (err) { 1264 if (err) {
1265 DPRINTFN(-1, ("usbd_new_device: setup default pipe failed\n")); 1265 DPRINTFN(-1, ("usbd_new_device: setup default pipe failed\n"));
1266 usbd_remove_device(dev, up); 1266 usbd_remove_device(dev, up);
1267 return err; 1267 return err;
1268 } 1268 }
1269 1269
1270 /* Assume 100mA bus powered for now. Changed when configured. */ 1270 /* Assume 100mA bus powered for now. Changed when configured. */
1271 dev->power = USB_MIN_POWER; 1271 dev->power = USB_MIN_POWER;
1272 dev->self_powered = 0; 1272 dev->self_powered = 0;
1273 1273
1274 DPRINTF(("usbd_new_device: new dev (addr %d), dev=%p, parent=%p\n", 1274 DPRINTF(("usbd_new_device: new dev (addr %d), dev=%p, parent=%p\n",
1275 addr, dev, parent)); 1275 addr, dev, parent));
1276 1276