| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ubt.c,v 1.48 2012/06/02 21:36:45 dsl Exp $ */ | | 1 | /* $NetBSD: ubt.c,v 1.49 2012/10/06 14:37:41 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006 Itronix Inc. | | 4 | * Copyright (c) 2006 Itronix Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Iain Hibbert for Itronix Inc. | | 7 | * Written by Iain Hibbert for Itronix Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -57,27 +57,27 @@ | | | @@ -57,27 +57,27 @@ |
57 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 57 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
58 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 58 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
59 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 59 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
60 | * POSSIBILITY OF SUCH DAMAGE. | | 60 | * POSSIBILITY OF SUCH DAMAGE. |
61 | */ | | 61 | */ |
62 | /* | | 62 | /* |
63 | * This driver originally written by Lennart Augustsson and David Sainty, | | 63 | * This driver originally written by Lennart Augustsson and David Sainty, |
64 | * but was mostly rewritten for the NetBSD Bluetooth protocol stack by | | 64 | * but was mostly rewritten for the NetBSD Bluetooth protocol stack by |
65 | * Iain Hibbert for Itronix, Inc using the FreeBSD ng_ubt.c driver as a | | 65 | * Iain Hibbert for Itronix, Inc using the FreeBSD ng_ubt.c driver as a |
66 | * reference. | | 66 | * reference. |
67 | */ | | 67 | */ |
68 | | | 68 | |
69 | #include <sys/cdefs.h> | | 69 | #include <sys/cdefs.h> |
70 | __KERNEL_RCSID(0, "$NetBSD: ubt.c,v 1.48 2012/06/02 21:36:45 dsl Exp $"); | | 70 | __KERNEL_RCSID(0, "$NetBSD: ubt.c,v 1.49 2012/10/06 14:37:41 christos Exp $"); |
71 | | | 71 | |
72 | #include <sys/param.h> | | 72 | #include <sys/param.h> |
73 | #include <sys/device.h> | | 73 | #include <sys/device.h> |
74 | #include <sys/ioctl.h> | | 74 | #include <sys/ioctl.h> |
75 | #include <sys/kernel.h> | | 75 | #include <sys/kernel.h> |
76 | #include <sys/malloc.h> | | 76 | #include <sys/malloc.h> |
77 | #include <sys/mbuf.h> | | 77 | #include <sys/mbuf.h> |
78 | #include <sys/proc.h> | | 78 | #include <sys/proc.h> |
79 | #include <sys/sysctl.h> | | 79 | #include <sys/sysctl.h> |
80 | #include <sys/systm.h> | | 80 | #include <sys/systm.h> |
81 | | | 81 | |
82 | #include <dev/usb/usb.h> | | 82 | #include <dev/usb/usb.h> |
83 | #include <dev/usb/usbdi.h> | | 83 | #include <dev/usb/usbdi.h> |
| @@ -295,46 +295,54 @@ static const struct hci_if ubt_hci = { | | | @@ -295,46 +295,54 @@ static const struct hci_if ubt_hci = { |
295 | | | 295 | |
296 | int ubt_match(device_t, cfdata_t, void *); | | 296 | int ubt_match(device_t, cfdata_t, void *); |
297 | void ubt_attach(device_t, device_t, void *); | | 297 | void ubt_attach(device_t, device_t, void *); |
298 | int ubt_detach(device_t, int); | | 298 | int ubt_detach(device_t, int); |
299 | int ubt_activate(device_t, enum devact); | | 299 | int ubt_activate(device_t, enum devact); |
300 | extern struct cfdriver ubt_cd; | | 300 | extern struct cfdriver ubt_cd; |
301 | CFATTACH_DECL_NEW(ubt, sizeof(struct ubt_softc), ubt_match, ubt_attach, ubt_detach, ubt_activate); | | 301 | CFATTACH_DECL_NEW(ubt, sizeof(struct ubt_softc), ubt_match, ubt_attach, ubt_detach, ubt_activate); |
302 | | | 302 | |
303 | static int ubt_set_isoc_config(struct ubt_softc *); | | 303 | static int ubt_set_isoc_config(struct ubt_softc *); |
304 | static int ubt_sysctl_config(SYSCTLFN_PROTO); | | 304 | static int ubt_sysctl_config(SYSCTLFN_PROTO); |
305 | static void ubt_abortdealloc(struct ubt_softc *); | | 305 | static void ubt_abortdealloc(struct ubt_softc *); |
306 | | | 306 | |
307 | /* | | 307 | /* |
308 | * Match against the whole device, since we want to take | | 308 | * To match or ignore forcibly, add |
309 | * both interfaces. If a device should be ignored then add | | | |
310 | * | | 309 | * |
311 | * { VendorID, ProductID } | | 310 | * { { VendorID, ProductID } , UMATCH_VENDOR_PRODUCT|UMATCH_NONE } |
312 | * | | 311 | * |
313 | * to the ubt_ignore list. | | 312 | * to the ubt_dev list. |
314 | */ | | 313 | */ |
315 | static const struct usb_devno ubt_ignore[] = { | | 314 | const struct ubt_devno { |
316 | { USB_VENDOR_BROADCOM, USB_PRODUCT_BROADCOM_BCM2033NF }, | | 315 | struct usb_devno devno; |
| | | 316 | int match; |
| | | 317 | } ubt_dev[] = { |
| | | 318 | { { USB_VENDOR_BROADCOM, USB_PRODUCT_BROADCOM_BCM2033NF }, |
| | | 319 | UMATCH_NONE }, |
| | | 320 | { { USB_VENDOR_APPLE, USB_PRODUCT_APPLE_BLUETOOTH_HOST_C }, |
| | | 321 | UMATCH_VENDOR_PRODUCT }, |
317 | }; | | 322 | }; |
| | | 323 | #define ubt_lookup(vendor, product) \ |
| | | 324 | ((const struct ubt_devno *)usb_lookup(ubt_dev, vendor, product)) |
318 | | | 325 | |
319 | int | | 326 | int |
320 | ubt_match(device_t parent, cfdata_t match, void *aux) | | 327 | ubt_match(device_t parent, cfdata_t match, void *aux) |
321 | { | | 328 | { |
322 | struct usb_attach_arg *uaa = aux; | | 329 | struct usb_attach_arg *uaa = aux; |
| | | 330 | const struct ubt_devno *dev; |
323 | | | 331 | |
324 | DPRINTFN(50, "ubt_match\n"); | | 332 | DPRINTFN(50, "ubt_match\n"); |
325 | | | 333 | |
326 | if (usb_lookup(ubt_ignore, uaa->vendor, uaa->product)) | | 334 | if ((dev = ubt_lookup(uaa->vendor, uaa->product)) != NULL) |
327 | return UMATCH_NONE; | | 335 | return dev->match; |
328 | | | 336 | |
329 | if (uaa->class == UDCLASS_WIRELESS | | 337 | if (uaa->class == UDCLASS_WIRELESS |
330 | && uaa->subclass == UDSUBCLASS_RF | | 338 | && uaa->subclass == UDSUBCLASS_RF |
331 | && uaa->proto == UDPROTO_BLUETOOTH) | | 339 | && uaa->proto == UDPROTO_BLUETOOTH) |
332 | return UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO; | | 340 | return UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO; |
333 | | | 341 | |
334 | return UMATCH_NONE; | | 342 | return UMATCH_NONE; |
335 | } | | 343 | } |
336 | | | 344 | |
337 | void | | 345 | void |
338 | ubt_attach(device_t parent, device_t self, void *aux) | | 346 | ubt_attach(device_t parent, device_t self, void *aux) |
339 | { | | 347 | { |
340 | struct ubt_softc *sc = device_private(self); | | 348 | struct ubt_softc *sc = device_private(self); |