usbd_open_pipe and usbd_open_pipe_intr take different flags! Make sure the value of USBD_MPSAFE doesn't conflict with flags for either of them, as it can be passed to both.diff -r1.149 -r1.150 src/sys/dev/usb/usbdi.c
(jmcneill)
--- src/sys/dev/usb/usbdi.c 2013/01/22 13:18:47 1.149
+++ src/sys/dev/usb/usbdi.c 2013/01/22 13:27:59 1.150
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbdi.c,v 1.149 2013/01/22 13:18:47 jmcneill Exp $ */ | 1 | /* $NetBSD: usbdi.c,v 1.150 2013/01/22 13:27:59 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). | 9 | * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.149 2013/01/22 13:18:47 jmcneill Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.150 2013/01/22 13:27:59 jmcneill Exp $"); | |
35 | 35 | |||
36 | #ifdef _KERNEL_OPT | 36 | #ifdef _KERNEL_OPT | |
37 | #include "opt_compat_netbsd.h" | 37 | #include "opt_compat_netbsd.h" | |
38 | #endif | 38 | #endif | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/kernel.h> | 42 | #include <sys/kernel.h> | |
43 | #include <sys/device.h> | 43 | #include <sys/device.h> | |
44 | #include <sys/malloc.h> | 44 | #include <sys/malloc.h> | |
45 | #include <sys/proc.h> | 45 | #include <sys/proc.h> | |
46 | #include <sys/bus.h> | 46 | #include <sys/bus.h> | |
47 | #include <sys/cpu.h> | 47 | #include <sys/cpu.h> | |
@@ -188,27 +188,28 @@ usbd_open_pipe_ival(usbd_interface_handl | @@ -188,27 +188,28 @@ usbd_open_pipe_ival(usbd_interface_handl | |||
188 | usbd_status | 188 | usbd_status | |
189 | usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address, | 189 | usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address, | |
190 | u_int8_t flags, usbd_pipe_handle *pipe, | 190 | u_int8_t flags, usbd_pipe_handle *pipe, | |
191 | usbd_private_handle priv, void *buffer, u_int32_t len, | 191 | usbd_private_handle priv, void *buffer, u_int32_t len, | |
192 | usbd_callback cb, int ival) | 192 | usbd_callback cb, int ival) | |
193 | { | 193 | { | |
194 | usbd_status err; | 194 | usbd_status err; | |
195 | usbd_xfer_handle xfer; | 195 | usbd_xfer_handle xfer; | |
196 | usbd_pipe_handle ipipe; | 196 | usbd_pipe_handle ipipe; | |
197 | 197 | |||
198 | DPRINTFN(3,("usbd_open_pipe_intr: address=0x%x flags=0x%x len=%d\n", | 198 | DPRINTFN(3,("usbd_open_pipe_intr: address=0x%x flags=0x%x len=%d\n", | |
199 | address, flags, len)); | 199 | address, flags, len)); | |
200 | 200 | |||
201 | err = usbd_open_pipe_ival(iface, address, USBD_EXCLUSIVE_USE | flags, | 201 | err = usbd_open_pipe_ival(iface, address, | |
202 | USBD_EXCLUSIVE_USE | (flags & USBD_MPSAFE), | |||
202 | &ipipe, ival); | 203 | &ipipe, ival); | |
203 | if (err) | 204 | if (err) | |
204 | return (err); | 205 | return (err); | |
205 | xfer = usbd_alloc_xfer(iface->device); | 206 | xfer = usbd_alloc_xfer(iface->device); | |
206 | if (xfer == NULL) { | 207 | if (xfer == NULL) { | |
207 | err = USBD_NOMEM; | 208 | err = USBD_NOMEM; | |
208 | goto bad1; | 209 | goto bad1; | |
209 | } | 210 | } | |
210 | usbd_setup_xfer(xfer, ipipe, priv, buffer, len, flags, | 211 | usbd_setup_xfer(xfer, ipipe, priv, buffer, len, flags, | |
211 | USBD_NO_TIMEOUT, cb); | 212 | USBD_NO_TIMEOUT, cb); | |
212 | ipipe->intrxfer = xfer; | 213 | ipipe->intrxfer = xfer; | |
213 | ipipe->repeat = 1; | 214 | ipipe->repeat = 1; | |
214 | err = usbd_transfer(xfer); | 215 | err = usbd_transfer(xfer); |
--- src/sys/dev/usb/usbdi.h 2013/01/22 12:48:07 1.86
+++ src/sys/dev/usb/usbdi.h 2013/01/22 13:27:59 1.87
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbdi.h,v 1.86 2013/01/22 12:48:07 jmcneill Exp $ */ | 1 | /* $NetBSD: usbdi.h,v 1.87 2013/01/22 13:27:59 jmcneill Exp $ */ | |
2 | /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ | 2 | /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 5 | * Copyright (c) 1998 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: | |
@@ -61,27 +61,27 @@ typedef enum { /* keep in sync with usb | @@ -61,27 +61,27 @@ typedef enum { /* keep in sync with usb | |||
61 | USBD_TIMEOUT, /* 15 */ | 61 | USBD_TIMEOUT, /* 15 */ | |
62 | USBD_SHORT_XFER, /* 16 */ | 62 | USBD_SHORT_XFER, /* 16 */ | |
63 | USBD_STALLED, /* 17 */ | 63 | USBD_STALLED, /* 17 */ | |
64 | USBD_INTERRUPTED, /* 18 */ | 64 | USBD_INTERRUPTED, /* 18 */ | |
65 | 65 | |||
66 | USBD_ERROR_MAX /* must be last */ | 66 | USBD_ERROR_MAX /* must be last */ | |
67 | } usbd_status; | 67 | } usbd_status; | |
68 | 68 | |||
69 | typedef void (*usbd_callback)(usbd_xfer_handle, usbd_private_handle, | 69 | typedef void (*usbd_callback)(usbd_xfer_handle, usbd_private_handle, | |
70 | usbd_status); | 70 | usbd_status); | |
71 | 71 | |||
72 | /* Open flags */ | 72 | /* Open flags */ | |
73 | #define USBD_EXCLUSIVE_USE 0x01 | 73 | #define USBD_EXCLUSIVE_USE 0x01 | |
74 | #define USBD_MPSAFE 0x02 | 74 | #define USBD_MPSAFE 0x80 | |
75 | 75 | |||
76 | /* Use default (specified by ep. desc.) interval on interrupt pipe */ | 76 | /* Use default (specified by ep. desc.) interval on interrupt pipe */ | |
77 | #define USBD_DEFAULT_INTERVAL (-1) | 77 | #define USBD_DEFAULT_INTERVAL (-1) | |
78 | 78 | |||
79 | /* Request flags */ | 79 | /* Request flags */ | |
80 | #define USBD_NO_COPY 0x01 /* do not copy data to DMA buffer */ | 80 | #define USBD_NO_COPY 0x01 /* do not copy data to DMA buffer */ | |
81 | #define USBD_SYNCHRONOUS 0x02 /* wait for completion */ | 81 | #define USBD_SYNCHRONOUS 0x02 /* wait for completion */ | |
82 | /* in usb.h #define USBD_SHORT_XFER_OK 0x04*/ /* allow short reads */ | 82 | /* in usb.h #define USBD_SHORT_XFER_OK 0x04*/ /* allow short reads */ | |
83 | #define USBD_FORCE_SHORT_XFER 0x08 /* force last short packet on write */ | 83 | #define USBD_FORCE_SHORT_XFER 0x08 /* force last short packet on write */ | |
84 | #define USBD_SYNCHRONOUS_SIG 0x10 /* if waiting for completion, | 84 | #define USBD_SYNCHRONOUS_SIG 0x10 /* if waiting for completion, | |
85 | * also take signals */ | 85 | * also take signals */ | |
86 | 86 | |||
87 | #define USBD_NO_TIMEOUT 0 | 87 | #define USBD_NO_TIMEOUT 0 | |
@@ -199,27 +199,27 @@ void usbd_clear_endpoint_stall_async_cb( | @@ -199,27 +199,27 @@ void usbd_clear_endpoint_stall_async_cb( | |||
199 | * perform (short) tasks that must have a process context. | 199 | * perform (short) tasks that must have a process context. | |
200 | */ | 200 | */ | |
201 | struct usb_task { | 201 | struct usb_task { | |
202 | TAILQ_ENTRY(usb_task) next; | 202 | TAILQ_ENTRY(usb_task) next; | |
203 | void (*fun)(void *); | 203 | void (*fun)(void *); | |
204 | void *arg; | 204 | void *arg; | |
205 | int queue; | 205 | int queue; | |
206 | int flags; | 206 | int flags; | |
207 | }; | 207 | }; | |
208 | #define USB_TASKQ_HC 0 | 208 | #define USB_TASKQ_HC 0 | |
209 | #define USB_TASKQ_DRIVER 1 | 209 | #define USB_TASKQ_DRIVER 1 | |
210 | #define USB_NUM_TASKQS 2 | 210 | #define USB_NUM_TASKQS 2 | |
211 | #define USB_TASKQ_NAMES {"usbtask-hc", "usbtask-dr"} | 211 | #define USB_TASKQ_NAMES {"usbtask-hc", "usbtask-dr"} | |
212 | #define USB_TASKQ_MPSAFE 0x02 | 212 | #define USB_TASKQ_MPSAFE 0x80 | |
213 | 213 | |||
214 | void usb_add_task(usbd_device_handle, struct usb_task *, int); | 214 | void usb_add_task(usbd_device_handle, struct usb_task *, int); | |
215 | void usb_rem_task(usbd_device_handle, struct usb_task *); | 215 | void usb_rem_task(usbd_device_handle, struct usb_task *); | |
216 | #define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = -1, (t)->flags = (fl)) | 216 | #define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = -1, (t)->flags = (fl)) | |
217 | 217 | |||
218 | struct usb_devno { | 218 | struct usb_devno { | |
219 | u_int16_t ud_vendor; | 219 | u_int16_t ud_vendor; | |
220 | u_int16_t ud_product; | 220 | u_int16_t ud_product; | |
221 | }; | 221 | }; | |
222 | const struct usb_devno *usb_match_device(const struct usb_devno *, | 222 | const struct usb_devno *usb_match_device(const struct usb_devno *, | |
223 | u_int, u_int, u_int16_t, u_int16_t); | 223 | u_int, u_int, u_int16_t, u_int16_t); | |
224 | #define usb_lookup(tbl, vendor, product) \ | 224 | #define usb_lookup(tbl, vendor, product) \ | |
225 | usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product)) | 225 | usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product)) |