diff options
-rw-r--r-- | MAINTAINERS | 87 | ||||
-rw-r--r-- | drivers/bluetooth/Kconfig | 10 | ||||
-rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/btusb.c | 282 | ||||
-rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/hci_usb.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/hci_vhci.c | 2 | ||||
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 2 | ||||
-rw-r--r-- | net/bluetooth/bnep/core.c | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 376 | ||||
-rw-r--r-- | net/bluetooth/l2cap.c | 2 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 2 | ||||
-rw-r--r-- | net/bluetooth/sco.c | 2 |
13 files changed, 476 insertions, 297 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 4c5e9fe0f7db..e7b68c22f1f2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -936,94 +936,19 @@ M: joern@lazybastard.org | |||
936 | L: linux-mtd@lists.infradead.org | 936 | L: linux-mtd@lists.infradead.org |
937 | S: Maintained | 937 | S: Maintained |
938 | 938 | ||
939 | BLUETOOTH SUBSYSTEM | 939 | BLUETOOTH DRIVERS |
940 | P: Marcel Holtmann | 940 | P: Marcel Holtmann |
941 | M: marcel@holtmann.org | 941 | M: marcel@holtmann.org |
942 | P: Maxim Krasnyansky | ||
943 | M: maxk@qualcomm.com | ||
944 | L: linux-bluetooth@vger.kernel.org | 942 | L: linux-bluetooth@vger.kernel.org |
945 | W: http://bluez.sf.net | 943 | W: http://www.bluez.org/ |
946 | W: http://www.bluez.org | ||
947 | W: http://www.holtmann.org/linux/bluetooth/ | ||
948 | T: git kernel.org:/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6.git | ||
949 | S: Maintained | ||
950 | |||
951 | BLUETOOTH RFCOMM LAYER | ||
952 | P: Marcel Holtmann | ||
953 | M: marcel@holtmann.org | ||
954 | P: Maxim Krasnyansky | ||
955 | M: maxk@qualcomm.com | ||
956 | S: Maintained | ||
957 | |||
958 | BLUETOOTH BNEP LAYER | ||
959 | P: Marcel Holtmann | ||
960 | M: marcel@holtmann.org | ||
961 | P: Maxim Krasnyansky | ||
962 | M: maxk@qualcomm.com | ||
963 | S: Maintained | ||
964 | |||
965 | BLUETOOTH CMTP LAYER | ||
966 | P: Marcel Holtmann | ||
967 | M: marcel@holtmann.org | ||
968 | S: Maintained | 944 | S: Maintained |
969 | 945 | ||
970 | BLUETOOTH HIDP LAYER | 946 | BLUETOOTH SUBSYSTEM |
971 | P: Marcel Holtmann | ||
972 | M: marcel@holtmann.org | ||
973 | S: Maintained | ||
974 | |||
975 | BLUETOOTH HCI UART DRIVER | ||
976 | P: Marcel Holtmann | ||
977 | M: marcel@holtmann.org | ||
978 | P: Maxim Krasnyansky | ||
979 | M: maxk@qualcomm.com | ||
980 | S: Maintained | ||
981 | |||
982 | BLUETOOTH HCI USB DRIVER | ||
983 | P: Marcel Holtmann | ||
984 | M: marcel@holtmann.org | ||
985 | P: Maxim Krasnyansky | ||
986 | M: maxk@qualcomm.com | ||
987 | S: Maintained | ||
988 | |||
989 | BLUETOOTH HCI BCM203X DRIVER | ||
990 | P: Marcel Holtmann | ||
991 | M: marcel@holtmann.org | ||
992 | S: Maintained | ||
993 | |||
994 | BLUETOOTH HCI BPA10X DRIVER | ||
995 | P: Marcel Holtmann | ||
996 | M: marcel@holtmann.org | ||
997 | S: Maintained | ||
998 | |||
999 | BLUETOOTH HCI BFUSB DRIVER | ||
1000 | P: Marcel Holtmann | ||
1001 | M: marcel@holtmann.org | ||
1002 | S: Maintained | ||
1003 | |||
1004 | BLUETOOTH HCI DTL1 DRIVER | ||
1005 | P: Marcel Holtmann | ||
1006 | M: marcel@holtmann.org | ||
1007 | S: Maintained | ||
1008 | |||
1009 | BLUETOOTH HCI BLUECARD DRIVER | ||
1010 | P: Marcel Holtmann | ||
1011 | M: marcel@holtmann.org | ||
1012 | S: Maintained | ||
1013 | |||
1014 | BLUETOOTH HCI BT3C DRIVER | ||
1015 | P: Marcel Holtmann | ||
1016 | M: marcel@holtmann.org | ||
1017 | S: Maintained | ||
1018 | |||
1019 | BLUETOOTH HCI BTUART DRIVER | ||
1020 | P: Marcel Holtmann | 947 | P: Marcel Holtmann |
1021 | M: marcel@holtmann.org | 948 | M: marcel@holtmann.org |
1022 | S: Maintained | 949 | L: linux-bluetooth@vger.kernel.org |
1023 | 950 | W: http://www.bluez.org/ | |
1024 | BLUETOOTH HCI VHCI DRIVER | 951 | T: git kernel.org:/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6.git |
1025 | P: Maxim Krasnyansky | ||
1026 | M: maxk@qualcomm.com | ||
1027 | S: Maintained | 952 | S: Maintained |
1028 | 953 | ||
1029 | BONDING DRIVER | 954 | BONDING DRIVER |
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index a235ca787465..7cb4029a5375 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig | |||
@@ -3,8 +3,8 @@ menu "Bluetooth device drivers" | |||
3 | depends on BT | 3 | depends on BT |
4 | 4 | ||
5 | config BT_HCIUSB | 5 | config BT_HCIUSB |
6 | tristate "HCI USB driver" | 6 | tristate "HCI USB driver (old version)" |
7 | depends on USB | 7 | depends on USB && BT_HCIBTUSB=n |
8 | help | 8 | help |
9 | Bluetooth HCI USB driver. | 9 | Bluetooth HCI USB driver. |
10 | This driver is required if you want to use Bluetooth devices with | 10 | This driver is required if you want to use Bluetooth devices with |
@@ -23,15 +23,13 @@ config BT_HCIUSB_SCO | |||
23 | Say Y here to compile support for SCO over HCI USB. | 23 | Say Y here to compile support for SCO over HCI USB. |
24 | 24 | ||
25 | config BT_HCIBTUSB | 25 | config BT_HCIBTUSB |
26 | tristate "HCI USB driver (alternate version)" | 26 | tristate "HCI USB driver" |
27 | depends on USB && EXPERIMENTAL && BT_HCIUSB=n | 27 | depends on USB |
28 | help | 28 | help |
29 | Bluetooth HCI USB driver. | 29 | Bluetooth HCI USB driver. |
30 | This driver is required if you want to use Bluetooth devices with | 30 | This driver is required if you want to use Bluetooth devices with |
31 | USB interface. | 31 | USB interface. |
32 | 32 | ||
33 | This driver is still experimental and has no SCO support. | ||
34 | |||
35 | Say Y here to compile support for Bluetooth USB devices into the | 33 | Say Y here to compile support for Bluetooth USB devices into the |
36 | kernel or say M to compile it as module (btusb). | 34 | kernel or say M to compile it as module (btusb). |
37 | 35 | ||
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 593b7c595038..27058477cc8b 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -60,7 +60,7 @@ | |||
60 | /* ======================== Module parameters ======================== */ | 60 | /* ======================== Module parameters ======================== */ |
61 | 61 | ||
62 | 62 | ||
63 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>, Jose Orlando Pereira <jop@di.uminho.pt>"); | 63 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
64 | MODULE_DESCRIPTION("Bluetooth driver for the 3Com Bluetooth PCMCIA card"); | 64 | MODULE_DESCRIPTION("Bluetooth driver for the 3Com Bluetooth PCMCIA card"); |
65 | MODULE_LICENSE("GPL"); | 65 | MODULE_LICENSE("GPL"); |
66 | MODULE_FIRMWARE("BT3CPCC.bin"); | 66 | MODULE_FIRMWARE("BT3CPCC.bin"); |
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 95ae9ba5661e..6a010681ecf3 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * | 2 | * |
3 | * Generic Bluetooth USB driver | 3 | * Generic Bluetooth USB driver |
4 | * | 4 | * |
5 | * Copyright (C) 2005-2007 Marcel Holtmann <marcel@holtmann.org> | 5 | * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org> |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
@@ -41,7 +41,7 @@ | |||
41 | #define BT_DBG(D...) | 41 | #define BT_DBG(D...) |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #define VERSION "0.2" | 44 | #define VERSION "0.3" |
45 | 45 | ||
46 | static int ignore_dga; | 46 | static int ignore_dga; |
47 | static int ignore_csr; | 47 | static int ignore_csr; |
@@ -160,12 +160,16 @@ static struct usb_device_id blacklist_table[] = { | |||
160 | { } /* Terminating entry */ | 160 | { } /* Terminating entry */ |
161 | }; | 161 | }; |
162 | 162 | ||
163 | #define BTUSB_MAX_ISOC_FRAMES 10 | ||
164 | |||
163 | #define BTUSB_INTR_RUNNING 0 | 165 | #define BTUSB_INTR_RUNNING 0 |
164 | #define BTUSB_BULK_RUNNING 1 | 166 | #define BTUSB_BULK_RUNNING 1 |
167 | #define BTUSB_ISOC_RUNNING 2 | ||
165 | 168 | ||
166 | struct btusb_data { | 169 | struct btusb_data { |
167 | struct hci_dev *hdev; | 170 | struct hci_dev *hdev; |
168 | struct usb_device *udev; | 171 | struct usb_device *udev; |
172 | struct usb_interface *isoc; | ||
169 | 173 | ||
170 | spinlock_t lock; | 174 | spinlock_t lock; |
171 | 175 | ||
@@ -176,10 +180,15 @@ struct btusb_data { | |||
176 | struct usb_anchor tx_anchor; | 180 | struct usb_anchor tx_anchor; |
177 | struct usb_anchor intr_anchor; | 181 | struct usb_anchor intr_anchor; |
178 | struct usb_anchor bulk_anchor; | 182 | struct usb_anchor bulk_anchor; |
183 | struct usb_anchor isoc_anchor; | ||
179 | 184 | ||
180 | struct usb_endpoint_descriptor *intr_ep; | 185 | struct usb_endpoint_descriptor *intr_ep; |
181 | struct usb_endpoint_descriptor *bulk_tx_ep; | 186 | struct usb_endpoint_descriptor *bulk_tx_ep; |
182 | struct usb_endpoint_descriptor *bulk_rx_ep; | 187 | struct usb_endpoint_descriptor *bulk_rx_ep; |
188 | struct usb_endpoint_descriptor *isoc_tx_ep; | ||
189 | struct usb_endpoint_descriptor *isoc_rx_ep; | ||
190 | |||
191 | int isoc_altsetting; | ||
183 | }; | 192 | }; |
184 | 193 | ||
185 | static void btusb_intr_complete(struct urb *urb) | 194 | static void btusb_intr_complete(struct urb *urb) |
@@ -195,6 +204,8 @@ static void btusb_intr_complete(struct urb *urb) | |||
195 | return; | 204 | return; |
196 | 205 | ||
197 | if (urb->status == 0) { | 206 | if (urb->status == 0) { |
207 | hdev->stat.byte_rx += urb->actual_length; | ||
208 | |||
198 | if (hci_recv_fragment(hdev, HCI_EVENT_PKT, | 209 | if (hci_recv_fragment(hdev, HCI_EVENT_PKT, |
199 | urb->transfer_buffer, | 210 | urb->transfer_buffer, |
200 | urb->actual_length) < 0) { | 211 | urb->actual_length) < 0) { |
@@ -216,7 +227,7 @@ static void btusb_intr_complete(struct urb *urb) | |||
216 | } | 227 | } |
217 | } | 228 | } |
218 | 229 | ||
219 | static inline int btusb_submit_intr_urb(struct hci_dev *hdev) | 230 | static int btusb_submit_intr_urb(struct hci_dev *hdev) |
220 | { | 231 | { |
221 | struct btusb_data *data = hdev->driver_data; | 232 | struct btusb_data *data = hdev->driver_data; |
222 | struct urb *urb; | 233 | struct urb *urb; |
@@ -226,6 +237,9 @@ static inline int btusb_submit_intr_urb(struct hci_dev *hdev) | |||
226 | 237 | ||
227 | BT_DBG("%s", hdev->name); | 238 | BT_DBG("%s", hdev->name); |
228 | 239 | ||
240 | if (!data->intr_ep) | ||
241 | return -ENODEV; | ||
242 | |||
229 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 243 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
230 | if (!urb) | 244 | if (!urb) |
231 | return -ENOMEM; | 245 | return -ENOMEM; |
@@ -274,6 +288,8 @@ static void btusb_bulk_complete(struct urb *urb) | |||
274 | return; | 288 | return; |
275 | 289 | ||
276 | if (urb->status == 0) { | 290 | if (urb->status == 0) { |
291 | hdev->stat.byte_rx += urb->actual_length; | ||
292 | |||
277 | if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT, | 293 | if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT, |
278 | urb->transfer_buffer, | 294 | urb->transfer_buffer, |
279 | urb->actual_length) < 0) { | 295 | urb->actual_length) < 0) { |
@@ -295,7 +311,7 @@ static void btusb_bulk_complete(struct urb *urb) | |||
295 | } | 311 | } |
296 | } | 312 | } |
297 | 313 | ||
298 | static inline int btusb_submit_bulk_urb(struct hci_dev *hdev) | 314 | static int btusb_submit_bulk_urb(struct hci_dev *hdev) |
299 | { | 315 | { |
300 | struct btusb_data *data = hdev->driver_data; | 316 | struct btusb_data *data = hdev->driver_data; |
301 | struct urb *urb; | 317 | struct urb *urb; |
@@ -305,6 +321,9 @@ static inline int btusb_submit_bulk_urb(struct hci_dev *hdev) | |||
305 | 321 | ||
306 | BT_DBG("%s", hdev->name); | 322 | BT_DBG("%s", hdev->name); |
307 | 323 | ||
324 | if (!data->bulk_rx_ep) | ||
325 | return -ENODEV; | ||
326 | |||
308 | urb = usb_alloc_urb(0, GFP_KERNEL); | 327 | urb = usb_alloc_urb(0, GFP_KERNEL); |
309 | if (!urb) | 328 | if (!urb) |
310 | return -ENOMEM; | 329 | return -ENOMEM; |
@@ -339,6 +358,127 @@ static inline int btusb_submit_bulk_urb(struct hci_dev *hdev) | |||
339 | return err; | 358 | return err; |
340 | } | 359 | } |
341 | 360 | ||
361 | static void btusb_isoc_complete(struct urb *urb) | ||
362 | { | ||
363 | struct hci_dev *hdev = urb->context; | ||
364 | struct btusb_data *data = hdev->driver_data; | ||
365 | int i, err; | ||
366 | |||
367 | BT_DBG("%s urb %p status %d count %d", hdev->name, | ||
368 | urb, urb->status, urb->actual_length); | ||
369 | |||
370 | if (!test_bit(HCI_RUNNING, &hdev->flags)) | ||
371 | return; | ||
372 | |||
373 | if (urb->status == 0) { | ||
374 | for (i = 0; i < urb->number_of_packets; i++) { | ||
375 | unsigned int offset = urb->iso_frame_desc[i].offset; | ||
376 | unsigned int length = urb->iso_frame_desc[i].actual_length; | ||
377 | |||
378 | if (urb->iso_frame_desc[i].status) | ||
379 | continue; | ||
380 | |||
381 | hdev->stat.byte_rx += length; | ||
382 | |||
383 | if (hci_recv_fragment(hdev, HCI_SCODATA_PKT, | ||
384 | urb->transfer_buffer + offset, | ||
385 | length) < 0) { | ||
386 | BT_ERR("%s corrupted SCO packet", hdev->name); | ||
387 | hdev->stat.err_rx++; | ||
388 | } | ||
389 | } | ||
390 | } | ||
391 | |||
392 | if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags)) | ||
393 | return; | ||
394 | |||
395 | usb_anchor_urb(urb, &data->isoc_anchor); | ||
396 | |||
397 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
398 | if (err < 0) { | ||
399 | BT_ERR("%s urb %p failed to resubmit (%d)", | ||
400 | hdev->name, urb, -err); | ||
401 | usb_unanchor_urb(urb); | ||
402 | } | ||
403 | } | ||
404 | |||
405 | static void inline __fill_isoc_descriptor(struct urb *urb, int len, int mtu) | ||
406 | { | ||
407 | int i, offset = 0; | ||
408 | |||
409 | BT_DBG("len %d mtu %d", len, mtu); | ||
410 | |||
411 | for (i = 0; i < BTUSB_MAX_ISOC_FRAMES && len >= mtu; | ||
412 | i++, offset += mtu, len -= mtu) { | ||
413 | urb->iso_frame_desc[i].offset = offset; | ||
414 | urb->iso_frame_desc[i].length = mtu; | ||
415 | } | ||
416 | |||
417 | if (len && i < BTUSB_MAX_ISOC_FRAMES) { | ||
418 | urb->iso_frame_desc[i].offset = offset; | ||
419 | urb->iso_frame_desc[i].length = len; | ||
420 | i++; | ||
421 | } | ||
422 | |||
423 | urb->number_of_packets = i; | ||
424 | } | ||
425 | |||
426 | static int btusb_submit_isoc_urb(struct hci_dev *hdev) | ||
427 | { | ||
428 | struct btusb_data *data = hdev->driver_data; | ||
429 | struct urb *urb; | ||
430 | unsigned char *buf; | ||
431 | unsigned int pipe; | ||
432 | int err, size; | ||
433 | |||
434 | BT_DBG("%s", hdev->name); | ||
435 | |||
436 | if (!data->isoc_rx_ep) | ||
437 | return -ENODEV; | ||
438 | |||
439 | urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_KERNEL); | ||
440 | if (!urb) | ||
441 | return -ENOMEM; | ||
442 | |||
443 | size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) * | ||
444 | BTUSB_MAX_ISOC_FRAMES; | ||
445 | |||
446 | buf = kmalloc(size, GFP_KERNEL); | ||
447 | if (!buf) { | ||
448 | usb_free_urb(urb); | ||
449 | return -ENOMEM; | ||
450 | } | ||
451 | |||
452 | pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress); | ||
453 | |||
454 | urb->dev = data->udev; | ||
455 | urb->pipe = pipe; | ||
456 | urb->context = hdev; | ||
457 | urb->complete = btusb_isoc_complete; | ||
458 | urb->interval = data->isoc_rx_ep->bInterval; | ||
459 | |||
460 | urb->transfer_flags = URB_FREE_BUFFER | URB_ISO_ASAP; | ||
461 | urb->transfer_buffer = buf; | ||
462 | urb->transfer_buffer_length = size; | ||
463 | |||
464 | __fill_isoc_descriptor(urb, size, | ||
465 | le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize)); | ||
466 | |||
467 | usb_anchor_urb(urb, &data->isoc_anchor); | ||
468 | |||
469 | err = usb_submit_urb(urb, GFP_KERNEL); | ||
470 | if (err < 0) { | ||
471 | BT_ERR("%s urb %p submission failed (%d)", | ||
472 | hdev->name, urb, -err); | ||
473 | usb_unanchor_urb(urb); | ||
474 | kfree(buf); | ||
475 | } | ||
476 | |||
477 | usb_free_urb(urb); | ||
478 | |||
479 | return err; | ||
480 | } | ||
481 | |||
342 | static void btusb_tx_complete(struct urb *urb) | 482 | static void btusb_tx_complete(struct urb *urb) |
343 | { | 483 | { |
344 | struct sk_buff *skb = urb->context; | 484 | struct sk_buff *skb = urb->context; |
@@ -392,6 +532,9 @@ static int btusb_close(struct hci_dev *hdev) | |||
392 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | 532 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) |
393 | return 0; | 533 | return 0; |
394 | 534 | ||
535 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | ||
536 | usb_kill_anchored_urbs(&data->intr_anchor); | ||
537 | |||
395 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | 538 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); |
396 | usb_kill_anchored_urbs(&data->bulk_anchor); | 539 | usb_kill_anchored_urbs(&data->bulk_anchor); |
397 | 540 | ||
@@ -453,6 +596,9 @@ static int btusb_send_frame(struct sk_buff *skb) | |||
453 | break; | 596 | break; |
454 | 597 | ||
455 | case HCI_ACLDATA_PKT: | 598 | case HCI_ACLDATA_PKT: |
599 | if (!data->bulk_tx_ep || hdev->conn_hash.acl_num < 1) | ||
600 | return -ENODEV; | ||
601 | |||
456 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 602 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
457 | if (!urb) | 603 | if (!urb) |
458 | return -ENOMEM; | 604 | return -ENOMEM; |
@@ -467,9 +613,31 @@ static int btusb_send_frame(struct sk_buff *skb) | |||
467 | break; | 613 | break; |
468 | 614 | ||
469 | case HCI_SCODATA_PKT: | 615 | case HCI_SCODATA_PKT: |
616 | if (!data->isoc_tx_ep || hdev->conn_hash.sco_num < 1) | ||
617 | return -ENODEV; | ||
618 | |||
619 | urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_ATOMIC); | ||
620 | if (!urb) | ||
621 | return -ENOMEM; | ||
622 | |||
623 | pipe = usb_sndisocpipe(data->udev, | ||
624 | data->isoc_tx_ep->bEndpointAddress); | ||
625 | |||
626 | urb->dev = data->udev; | ||
627 | urb->pipe = pipe; | ||
628 | urb->context = skb; | ||
629 | urb->complete = btusb_tx_complete; | ||
630 | urb->interval = data->isoc_tx_ep->bInterval; | ||
631 | |||
632 | urb->transfer_flags = URB_ISO_ASAP; | ||
633 | urb->transfer_buffer = skb->data; | ||
634 | urb->transfer_buffer_length = skb->len; | ||
635 | |||
636 | __fill_isoc_descriptor(urb, skb->len, | ||
637 | le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize)); | ||
638 | |||
470 | hdev->stat.sco_tx++; | 639 | hdev->stat.sco_tx++; |
471 | kfree_skb(skb); | 640 | break; |
472 | return 0; | ||
473 | 641 | ||
474 | default: | 642 | default: |
475 | return -EILSEQ; | 643 | return -EILSEQ; |
@@ -508,22 +676,86 @@ static void btusb_notify(struct hci_dev *hdev, unsigned int evt) | |||
508 | schedule_work(&data->work); | 676 | schedule_work(&data->work); |
509 | } | 677 | } |
510 | 678 | ||
679 | static int inline __set_isoc_interface(struct hci_dev *hdev, int altsetting) | ||
680 | { | ||
681 | struct btusb_data *data = hdev->driver_data; | ||
682 | struct usb_interface *intf = data->isoc; | ||
683 | struct usb_endpoint_descriptor *ep_desc; | ||
684 | int i, err; | ||
685 | |||
686 | if (!data->isoc) | ||
687 | return -ENODEV; | ||
688 | |||
689 | err = usb_set_interface(data->udev, 1, altsetting); | ||
690 | if (err < 0) { | ||
691 | BT_ERR("%s setting interface failed (%d)", hdev->name, -err); | ||
692 | return err; | ||
693 | } | ||
694 | |||
695 | data->isoc_altsetting = altsetting; | ||
696 | |||
697 | data->isoc_tx_ep = NULL; | ||
698 | data->isoc_rx_ep = NULL; | ||
699 | |||
700 | for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { | ||
701 | ep_desc = &intf->cur_altsetting->endpoint[i].desc; | ||
702 | |||
703 | if (!data->isoc_tx_ep && usb_endpoint_is_isoc_out(ep_desc)) { | ||
704 | data->isoc_tx_ep = ep_desc; | ||
705 | continue; | ||
706 | } | ||
707 | |||
708 | if (!data->isoc_rx_ep && usb_endpoint_is_isoc_in(ep_desc)) { | ||
709 | data->isoc_rx_ep = ep_desc; | ||
710 | continue; | ||
711 | } | ||
712 | } | ||
713 | |||
714 | if (!data->isoc_tx_ep || !data->isoc_rx_ep) { | ||
715 | BT_ERR("%s invalid SCO descriptors", hdev->name); | ||
716 | return -ENODEV; | ||
717 | } | ||
718 | |||
719 | return 0; | ||
720 | } | ||
721 | |||
511 | static void btusb_work(struct work_struct *work) | 722 | static void btusb_work(struct work_struct *work) |
512 | { | 723 | { |
513 | struct btusb_data *data = container_of(work, struct btusb_data, work); | 724 | struct btusb_data *data = container_of(work, struct btusb_data, work); |
514 | struct hci_dev *hdev = data->hdev; | 725 | struct hci_dev *hdev = data->hdev; |
515 | 726 | ||
516 | if (hdev->conn_hash.acl_num == 0) { | 727 | if (hdev->conn_hash.acl_num > 0) { |
728 | if (!test_and_set_bit(BTUSB_BULK_RUNNING, &data->flags)) { | ||
729 | if (btusb_submit_bulk_urb(hdev) < 0) | ||
730 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | ||
731 | else | ||
732 | btusb_submit_bulk_urb(hdev); | ||
733 | } | ||
734 | } else { | ||
517 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | 735 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); |
518 | usb_kill_anchored_urbs(&data->bulk_anchor); | 736 | usb_kill_anchored_urbs(&data->bulk_anchor); |
519 | return; | ||
520 | } | 737 | } |
521 | 738 | ||
522 | if (!test_and_set_bit(BTUSB_BULK_RUNNING, &data->flags)) { | 739 | if (hdev->conn_hash.sco_num > 0) { |
523 | if (btusb_submit_bulk_urb(hdev) < 0) | 740 | if (data->isoc_altsetting != 2) { |
524 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | 741 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); |
525 | else | 742 | usb_kill_anchored_urbs(&data->isoc_anchor); |
526 | btusb_submit_bulk_urb(hdev); | 743 | |
744 | if (__set_isoc_interface(hdev, 2) < 0) | ||
745 | return; | ||
746 | } | ||
747 | |||
748 | if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) { | ||
749 | if (btusb_submit_isoc_urb(hdev) < 0) | ||
750 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | ||
751 | else | ||
752 | btusb_submit_isoc_urb(hdev); | ||
753 | } | ||
754 | } else { | ||
755 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | ||
756 | usb_kill_anchored_urbs(&data->isoc_anchor); | ||
757 | |||
758 | __set_isoc_interface(hdev, 0); | ||
527 | } | 759 | } |
528 | } | 760 | } |
529 | 761 | ||
@@ -597,6 +829,7 @@ static int btusb_probe(struct usb_interface *intf, | |||
597 | init_usb_anchor(&data->tx_anchor); | 829 | init_usb_anchor(&data->tx_anchor); |
598 | init_usb_anchor(&data->intr_anchor); | 830 | init_usb_anchor(&data->intr_anchor); |
599 | init_usb_anchor(&data->bulk_anchor); | 831 | init_usb_anchor(&data->bulk_anchor); |
832 | init_usb_anchor(&data->isoc_anchor); | ||
600 | 833 | ||
601 | hdev = hci_alloc_dev(); | 834 | hdev = hci_alloc_dev(); |
602 | if (!hdev) { | 835 | if (!hdev) { |
@@ -620,6 +853,9 @@ static int btusb_probe(struct usb_interface *intf, | |||
620 | 853 | ||
621 | hdev->owner = THIS_MODULE; | 854 | hdev->owner = THIS_MODULE; |
622 | 855 | ||
856 | /* interface numbers are hardcoded in the spec */ | ||
857 | data->isoc = usb_ifnum_to_if(data->udev, 1); | ||
858 | |||
623 | if (reset || id->driver_info & BTUSB_RESET) | 859 | if (reset || id->driver_info & BTUSB_RESET) |
624 | set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); | 860 | set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); |
625 | 861 | ||
@@ -628,11 +864,16 @@ static int btusb_probe(struct usb_interface *intf, | |||
628 | set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); | 864 | set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); |
629 | } | 865 | } |
630 | 866 | ||
867 | if (id->driver_info & BTUSB_BROKEN_ISOC) | ||
868 | data->isoc = NULL; | ||
869 | |||
631 | if (id->driver_info & BTUSB_SNIFFER) { | 870 | if (id->driver_info & BTUSB_SNIFFER) { |
632 | struct usb_device *udev = interface_to_usbdev(intf); | 871 | struct usb_device *udev = data->udev; |
633 | 872 | ||
634 | if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) | 873 | if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) |
635 | set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); | 874 | set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); |
875 | |||
876 | data->isoc = NULL; | ||
636 | } | 877 | } |
637 | 878 | ||
638 | if (id->driver_info & BTUSB_BCM92035) { | 879 | if (id->driver_info & BTUSB_BCM92035) { |
@@ -646,6 +887,16 @@ static int btusb_probe(struct usb_interface *intf, | |||
646 | } | 887 | } |
647 | } | 888 | } |
648 | 889 | ||
890 | if (data->isoc) { | ||
891 | err = usb_driver_claim_interface(&btusb_driver, | ||
892 | data->isoc, NULL); | ||
893 | if (err < 0) { | ||
894 | hci_free_dev(hdev); | ||
895 | kfree(data); | ||
896 | return err; | ||
897 | } | ||
898 | } | ||
899 | |||
649 | err = hci_register_dev(hdev); | 900 | err = hci_register_dev(hdev); |
650 | if (err < 0) { | 901 | if (err < 0) { |
651 | hci_free_dev(hdev); | 902 | hci_free_dev(hdev); |
@@ -670,6 +921,9 @@ static void btusb_disconnect(struct usb_interface *intf) | |||
670 | 921 | ||
671 | hdev = data->hdev; | 922 | hdev = data->hdev; |
672 | 923 | ||
924 | if (data->isoc) | ||
925 | usb_driver_release_interface(&btusb_driver, data->isoc); | ||
926 | |||
673 | usb_set_intfdata(intf, NULL); | 927 | usb_set_intfdata(intf, NULL); |
674 | 928 | ||
675 | hci_unregister_dev(hdev); | 929 | hci_unregister_dev(hdev); |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 69df187d74ce..8dfcf77cb717 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -577,7 +577,7 @@ module_exit(hci_uart_exit); | |||
577 | module_param(reset, bool, 0644); | 577 | module_param(reset, bool, 0644); |
578 | MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); | 578 | MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); |
579 | 579 | ||
580 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 580 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
581 | MODULE_DESCRIPTION("Bluetooth HCI UART driver ver " VERSION); | 581 | MODULE_DESCRIPTION("Bluetooth HCI UART driver ver " VERSION); |
582 | MODULE_VERSION(VERSION); | 582 | MODULE_VERSION(VERSION); |
583 | MODULE_LICENSE("GPL"); | 583 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index e397572bf574..3c453924f838 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c | |||
@@ -1130,7 +1130,7 @@ module_param(isoc, int, 0644); | |||
1130 | MODULE_PARM_DESC(isoc, "Set isochronous transfers for SCO over HCI support"); | 1130 | MODULE_PARM_DESC(isoc, "Set isochronous transfers for SCO over HCI support"); |
1131 | #endif | 1131 | #endif |
1132 | 1132 | ||
1133 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 1133 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
1134 | MODULE_DESCRIPTION("Bluetooth HCI USB driver ver " VERSION); | 1134 | MODULE_DESCRIPTION("Bluetooth HCI USB driver ver " VERSION); |
1135 | MODULE_VERSION(VERSION); | 1135 | MODULE_VERSION(VERSION); |
1136 | MODULE_LICENSE("GPL"); | 1136 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index d97700aa54a9..7320a71b6368 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c | |||
@@ -377,7 +377,7 @@ module_exit(vhci_exit); | |||
377 | module_param(minor, int, 0444); | 377 | module_param(minor, int, 0444); |
378 | MODULE_PARM_DESC(minor, "Miscellaneous minor device number"); | 378 | MODULE_PARM_DESC(minor, "Miscellaneous minor device number"); |
379 | 379 | ||
380 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 380 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
381 | MODULE_DESCRIPTION("Bluetooth virtual HCI driver ver " VERSION); | 381 | MODULE_DESCRIPTION("Bluetooth virtual HCI driver ver " VERSION); |
382 | MODULE_VERSION(VERSION); | 382 | MODULE_VERSION(VERSION); |
383 | MODULE_LICENSE("GPL"); | 383 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 4e59df5f8e05..1edfdf4c095b 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -456,7 +456,7 @@ static void __exit bt_exit(void) | |||
456 | subsys_initcall(bt_init); | 456 | subsys_initcall(bt_init); |
457 | module_exit(bt_exit); | 457 | module_exit(bt_exit); |
458 | 458 | ||
459 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 459 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
460 | MODULE_DESCRIPTION("Bluetooth Core ver " VERSION); | 460 | MODULE_DESCRIPTION("Bluetooth Core ver " VERSION); |
461 | MODULE_VERSION(VERSION); | 461 | MODULE_VERSION(VERSION); |
462 | MODULE_LICENSE("GPL"); | 462 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 12bba6207a8d..80ba30cf4b68 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -736,7 +736,7 @@ MODULE_PARM_DESC(compress_src, "Compress sources headers"); | |||
736 | module_param(compress_dst, bool, 0644); | 736 | module_param(compress_dst, bool, 0644); |
737 | MODULE_PARM_DESC(compress_dst, "Compress destination headers"); | 737 | MODULE_PARM_DESC(compress_dst, "Compress destination headers"); |
738 | 738 | ||
739 | MODULE_AUTHOR("David Libault <david.libault@inventel.fr>, Maxim Krasnyansky <maxk@qualcomm.com>"); | 739 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
740 | MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION); | 740 | MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION); |
741 | MODULE_VERSION(VERSION); | 741 | MODULE_VERSION(VERSION); |
742 | MODULE_LICENSE("GPL"); | 742 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index c85bf8f678dc..f4f6615cad9f 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -3,8 +3,6 @@ | |||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | 5 | ||
6 | #include <linux/platform_device.h> | ||
7 | |||
8 | #include <net/bluetooth/bluetooth.h> | 6 | #include <net/bluetooth/bluetooth.h> |
9 | #include <net/bluetooth/hci_core.h> | 7 | #include <net/bluetooth/hci_core.h> |
10 | 8 | ||
@@ -12,10 +10,164 @@ | |||
12 | #undef BT_DBG | 10 | #undef BT_DBG |
13 | #define BT_DBG(D...) | 11 | #define BT_DBG(D...) |
14 | #endif | 12 | #endif |
13 | |||
14 | struct class *bt_class = NULL; | ||
15 | EXPORT_SYMBOL_GPL(bt_class); | ||
16 | |||
15 | static struct workqueue_struct *btaddconn; | 17 | static struct workqueue_struct *btaddconn; |
16 | static struct workqueue_struct *btdelconn; | 18 | static struct workqueue_struct *btdelconn; |
17 | 19 | ||
18 | static inline char *typetostr(int type) | 20 | static inline char *link_typetostr(int type) |
21 | { | ||
22 | switch (type) { | ||
23 | case ACL_LINK: | ||
24 | return "ACL"; | ||
25 | case SCO_LINK: | ||
26 | return "SCO"; | ||
27 | case ESCO_LINK: | ||
28 | return "eSCO"; | ||
29 | default: | ||
30 | return "UNKNOWN"; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf) | ||
35 | { | ||
36 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
37 | return sprintf(buf, "%s\n", link_typetostr(conn->type)); | ||
38 | } | ||
39 | |||
40 | static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf) | ||
41 | { | ||
42 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
43 | bdaddr_t bdaddr; | ||
44 | baswap(&bdaddr, &conn->dst); | ||
45 | return sprintf(buf, "%s\n", batostr(&bdaddr)); | ||
46 | } | ||
47 | |||
48 | static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf) | ||
49 | { | ||
50 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
51 | |||
52 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | ||
53 | conn->features[0], conn->features[1], | ||
54 | conn->features[2], conn->features[3], | ||
55 | conn->features[4], conn->features[5], | ||
56 | conn->features[6], conn->features[7]); | ||
57 | } | ||
58 | |||
59 | #define LINK_ATTR(_name,_mode,_show,_store) \ | ||
60 | struct device_attribute link_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
61 | |||
62 | static LINK_ATTR(type, S_IRUGO, show_link_type, NULL); | ||
63 | static LINK_ATTR(address, S_IRUGO, show_link_address, NULL); | ||
64 | static LINK_ATTR(features, S_IRUGO, show_link_features, NULL); | ||
65 | |||
66 | static struct attribute *bt_link_attrs[] = { | ||
67 | &link_attr_type.attr, | ||
68 | &link_attr_address.attr, | ||
69 | &link_attr_features.attr, | ||
70 | NULL | ||
71 | }; | ||
72 | |||
73 | static struct attribute_group bt_link_group = { | ||
74 | .attrs = bt_link_attrs, | ||
75 | }; | ||
76 | |||
77 | static struct attribute_group *bt_link_groups[] = { | ||
78 | &bt_link_group, | ||
79 | NULL | ||
80 | }; | ||
81 | |||
82 | static void bt_link_release(struct device *dev) | ||
83 | { | ||
84 | void *data = dev_get_drvdata(dev); | ||
85 | kfree(data); | ||
86 | } | ||
87 | |||
88 | static struct device_type bt_link = { | ||
89 | .name = "link", | ||
90 | .groups = bt_link_groups, | ||
91 | .release = bt_link_release, | ||
92 | }; | ||
93 | |||
94 | static void add_conn(struct work_struct *work) | ||
95 | { | ||
96 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
97 | |||
98 | flush_workqueue(btdelconn); | ||
99 | |||
100 | if (device_add(&conn->dev) < 0) { | ||
101 | BT_ERR("Failed to register connection device"); | ||
102 | return; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
107 | { | ||
108 | struct hci_dev *hdev = conn->hdev; | ||
109 | |||
110 | BT_DBG("conn %p", conn); | ||
111 | |||
112 | conn->dev.type = &bt_link; | ||
113 | conn->dev.class = bt_class; | ||
114 | conn->dev.parent = &hdev->dev; | ||
115 | |||
116 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", | ||
117 | hdev->name, conn->handle); | ||
118 | |||
119 | dev_set_drvdata(&conn->dev, conn); | ||
120 | |||
121 | device_initialize(&conn->dev); | ||
122 | |||
123 | INIT_WORK(&conn->work, add_conn); | ||
124 | |||
125 | queue_work(btaddconn, &conn->work); | ||
126 | } | ||
127 | |||
128 | /* | ||
129 | * The rfcomm tty device will possibly retain even when conn | ||
130 | * is down, and sysfs doesn't support move zombie device, | ||
131 | * so we should move the device before conn device is destroyed. | ||
132 | */ | ||
133 | static int __match_tty(struct device *dev, void *data) | ||
134 | { | ||
135 | return !strncmp(dev->bus_id, "rfcomm", 6); | ||
136 | } | ||
137 | |||
138 | static void del_conn(struct work_struct *work) | ||
139 | { | ||
140 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
141 | struct hci_dev *hdev = conn->hdev; | ||
142 | |||
143 | while (1) { | ||
144 | struct device *dev; | ||
145 | |||
146 | dev = device_find_child(&conn->dev, NULL, __match_tty); | ||
147 | if (!dev) | ||
148 | break; | ||
149 | device_move(dev, NULL); | ||
150 | put_device(dev); | ||
151 | } | ||
152 | |||
153 | device_del(&conn->dev); | ||
154 | put_device(&conn->dev); | ||
155 | hci_dev_put(hdev); | ||
156 | } | ||
157 | |||
158 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
159 | { | ||
160 | BT_DBG("conn %p", conn); | ||
161 | |||
162 | if (!device_is_registered(&conn->dev)) | ||
163 | return; | ||
164 | |||
165 | INIT_WORK(&conn->work, del_conn); | ||
166 | |||
167 | queue_work(btdelconn, &conn->work); | ||
168 | } | ||
169 | |||
170 | static inline char *host_typetostr(int type) | ||
19 | { | 171 | { |
20 | switch (type) { | 172 | switch (type) { |
21 | case HCI_VIRTUAL: | 173 | case HCI_VIRTUAL: |
@@ -40,7 +192,7 @@ static inline char *typetostr(int type) | |||
40 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) | 192 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) |
41 | { | 193 | { |
42 | struct hci_dev *hdev = dev_get_drvdata(dev); | 194 | struct hci_dev *hdev = dev_get_drvdata(dev); |
43 | return sprintf(buf, "%s\n", typetostr(hdev->type)); | 195 | return sprintf(buf, "%s\n", host_typetostr(hdev->type)); |
44 | } | 196 | } |
45 | 197 | ||
46 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 198 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -221,183 +373,62 @@ static DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR, | |||
221 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, | 373 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, |
222 | show_sniff_min_interval, store_sniff_min_interval); | 374 | show_sniff_min_interval, store_sniff_min_interval); |
223 | 375 | ||
224 | static struct device_attribute *bt_attrs[] = { | 376 | static struct attribute *bt_host_attrs[] = { |
225 | &dev_attr_type, | 377 | &dev_attr_type.attr, |
226 | &dev_attr_name, | 378 | &dev_attr_name.attr, |
227 | &dev_attr_class, | 379 | &dev_attr_class.attr, |
228 | &dev_attr_address, | 380 | &dev_attr_address.attr, |
229 | &dev_attr_features, | 381 | &dev_attr_features.attr, |
230 | &dev_attr_manufacturer, | 382 | &dev_attr_manufacturer.attr, |
231 | &dev_attr_hci_version, | 383 | &dev_attr_hci_version.attr, |
232 | &dev_attr_hci_revision, | 384 | &dev_attr_hci_revision.attr, |
233 | &dev_attr_inquiry_cache, | 385 | &dev_attr_inquiry_cache.attr, |
234 | &dev_attr_idle_timeout, | 386 | &dev_attr_idle_timeout.attr, |
235 | &dev_attr_sniff_max_interval, | 387 | &dev_attr_sniff_max_interval.attr, |
236 | &dev_attr_sniff_min_interval, | 388 | &dev_attr_sniff_min_interval.attr, |
237 | NULL | 389 | NULL |
238 | }; | 390 | }; |
239 | 391 | ||
240 | static ssize_t show_conn_type(struct device *dev, struct device_attribute *attr, char *buf) | 392 | static struct attribute_group bt_host_group = { |
241 | { | 393 | .attrs = bt_host_attrs, |
242 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
243 | return sprintf(buf, "%s\n", conn->type == ACL_LINK ? "ACL" : "SCO"); | ||
244 | } | ||
245 | |||
246 | static ssize_t show_conn_address(struct device *dev, struct device_attribute *attr, char *buf) | ||
247 | { | ||
248 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
249 | bdaddr_t bdaddr; | ||
250 | baswap(&bdaddr, &conn->dst); | ||
251 | return sprintf(buf, "%s\n", batostr(&bdaddr)); | ||
252 | } | ||
253 | |||
254 | static ssize_t show_conn_features(struct device *dev, struct device_attribute *attr, char *buf) | ||
255 | { | ||
256 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
257 | |||
258 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | ||
259 | conn->features[0], conn->features[1], | ||
260 | conn->features[2], conn->features[3], | ||
261 | conn->features[4], conn->features[5], | ||
262 | conn->features[6], conn->features[7]); | ||
263 | } | ||
264 | |||
265 | #define CONN_ATTR(_name,_mode,_show,_store) \ | ||
266 | struct device_attribute conn_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
267 | |||
268 | static CONN_ATTR(type, S_IRUGO, show_conn_type, NULL); | ||
269 | static CONN_ATTR(address, S_IRUGO, show_conn_address, NULL); | ||
270 | static CONN_ATTR(features, S_IRUGO, show_conn_features, NULL); | ||
271 | |||
272 | static struct device_attribute *conn_attrs[] = { | ||
273 | &conn_attr_type, | ||
274 | &conn_attr_address, | ||
275 | &conn_attr_features, | ||
276 | NULL | ||
277 | }; | 394 | }; |
278 | 395 | ||
279 | struct class *bt_class = NULL; | 396 | static struct attribute_group *bt_host_groups[] = { |
280 | EXPORT_SYMBOL_GPL(bt_class); | 397 | &bt_host_group, |
281 | 398 | NULL | |
282 | static struct bus_type bt_bus = { | ||
283 | .name = "bluetooth", | ||
284 | }; | 399 | }; |
285 | 400 | ||
286 | static struct platform_device *bt_platform; | 401 | static void bt_host_release(struct device *dev) |
287 | |||
288 | static void bt_release(struct device *dev) | ||
289 | { | 402 | { |
290 | void *data = dev_get_drvdata(dev); | 403 | void *data = dev_get_drvdata(dev); |
291 | kfree(data); | 404 | kfree(data); |
292 | } | 405 | } |
293 | 406 | ||
294 | static void add_conn(struct work_struct *work) | 407 | static struct device_type bt_host = { |
295 | { | 408 | .name = "host", |
296 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | 409 | .groups = bt_host_groups, |
297 | int i; | 410 | .release = bt_host_release, |
298 | 411 | }; | |
299 | flush_workqueue(btdelconn); | ||
300 | |||
301 | if (device_add(&conn->dev) < 0) { | ||
302 | BT_ERR("Failed to register connection device"); | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | for (i = 0; conn_attrs[i]; i++) | ||
307 | if (device_create_file(&conn->dev, conn_attrs[i]) < 0) | ||
308 | BT_ERR("Failed to create connection attribute"); | ||
309 | } | ||
310 | |||
311 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
312 | { | ||
313 | struct hci_dev *hdev = conn->hdev; | ||
314 | |||
315 | BT_DBG("conn %p", conn); | ||
316 | |||
317 | conn->dev.bus = &bt_bus; | ||
318 | conn->dev.parent = &hdev->dev; | ||
319 | |||
320 | conn->dev.release = bt_release; | ||
321 | |||
322 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", | ||
323 | hdev->name, conn->handle); | ||
324 | |||
325 | dev_set_drvdata(&conn->dev, conn); | ||
326 | |||
327 | device_initialize(&conn->dev); | ||
328 | |||
329 | INIT_WORK(&conn->work, add_conn); | ||
330 | |||
331 | queue_work(btaddconn, &conn->work); | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * The rfcomm tty device will possibly retain even when conn | ||
336 | * is down, and sysfs doesn't support move zombie device, | ||
337 | * so we should move the device before conn device is destroyed. | ||
338 | */ | ||
339 | static int __match_tty(struct device *dev, void *data) | ||
340 | { | ||
341 | return !strncmp(dev->bus_id, "rfcomm", 6); | ||
342 | } | ||
343 | |||
344 | static void del_conn(struct work_struct *work) | ||
345 | { | ||
346 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
347 | struct hci_dev *hdev = conn->hdev; | ||
348 | |||
349 | while (1) { | ||
350 | struct device *dev; | ||
351 | |||
352 | dev = device_find_child(&conn->dev, NULL, __match_tty); | ||
353 | if (!dev) | ||
354 | break; | ||
355 | device_move(dev, NULL); | ||
356 | put_device(dev); | ||
357 | } | ||
358 | |||
359 | device_del(&conn->dev); | ||
360 | put_device(&conn->dev); | ||
361 | hci_dev_put(hdev); | ||
362 | } | ||
363 | |||
364 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
365 | { | ||
366 | BT_DBG("conn %p", conn); | ||
367 | |||
368 | if (!device_is_registered(&conn->dev)) | ||
369 | return; | ||
370 | |||
371 | INIT_WORK(&conn->work, del_conn); | ||
372 | |||
373 | queue_work(btdelconn, &conn->work); | ||
374 | } | ||
375 | 412 | ||
376 | int hci_register_sysfs(struct hci_dev *hdev) | 413 | int hci_register_sysfs(struct hci_dev *hdev) |
377 | { | 414 | { |
378 | struct device *dev = &hdev->dev; | 415 | struct device *dev = &hdev->dev; |
379 | unsigned int i; | ||
380 | int err; | 416 | int err; |
381 | 417 | ||
382 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); | 418 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); |
383 | 419 | ||
384 | dev->bus = &bt_bus; | 420 | dev->type = &bt_host; |
421 | dev->class = bt_class; | ||
385 | dev->parent = hdev->parent; | 422 | dev->parent = hdev->parent; |
386 | 423 | ||
387 | strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); | 424 | strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); |
388 | 425 | ||
389 | dev->release = bt_release; | ||
390 | |||
391 | dev_set_drvdata(dev, hdev); | 426 | dev_set_drvdata(dev, hdev); |
392 | 427 | ||
393 | err = device_register(dev); | 428 | err = device_register(dev); |
394 | if (err < 0) | 429 | if (err < 0) |
395 | return err; | 430 | return err; |
396 | 431 | ||
397 | for (i = 0; bt_attrs[i]; i++) | ||
398 | if (device_create_file(dev, bt_attrs[i]) < 0) | ||
399 | BT_ERR("Failed to create device attribute"); | ||
400 | |||
401 | return 0; | 432 | return 0; |
402 | } | 433 | } |
403 | 434 | ||
@@ -410,59 +441,30 @@ void hci_unregister_sysfs(struct hci_dev *hdev) | |||
410 | 441 | ||
411 | int __init bt_sysfs_init(void) | 442 | int __init bt_sysfs_init(void) |
412 | { | 443 | { |
413 | int err; | ||
414 | |||
415 | btaddconn = create_singlethread_workqueue("btaddconn"); | 444 | btaddconn = create_singlethread_workqueue("btaddconn"); |
416 | if (!btaddconn) { | 445 | if (!btaddconn) |
417 | err = -ENOMEM; | 446 | return -ENOMEM; |
418 | goto out; | ||
419 | } | ||
420 | 447 | ||
421 | btdelconn = create_singlethread_workqueue("btdelconn"); | 448 | btdelconn = create_singlethread_workqueue("btdelconn"); |
422 | if (!btdelconn) { | 449 | if (!btdelconn) { |
423 | err = -ENOMEM; | 450 | destroy_workqueue(btaddconn); |
424 | goto out_del; | 451 | return -ENOMEM; |
425 | } | ||
426 | |||
427 | bt_platform = platform_device_register_simple("bluetooth", -1, NULL, 0); | ||
428 | if (IS_ERR(bt_platform)) { | ||
429 | err = PTR_ERR(bt_platform); | ||
430 | goto out_platform; | ||
431 | } | 452 | } |
432 | 453 | ||
433 | err = bus_register(&bt_bus); | ||
434 | if (err < 0) | ||
435 | goto out_bus; | ||
436 | |||
437 | bt_class = class_create(THIS_MODULE, "bluetooth"); | 454 | bt_class = class_create(THIS_MODULE, "bluetooth"); |
438 | if (IS_ERR(bt_class)) { | 455 | if (IS_ERR(bt_class)) { |
439 | err = PTR_ERR(bt_class); | 456 | destroy_workqueue(btdelconn); |
440 | goto out_class; | 457 | destroy_workqueue(btaddconn); |
458 | return PTR_ERR(bt_class); | ||
441 | } | 459 | } |
442 | 460 | ||
443 | return 0; | 461 | return 0; |
444 | |||
445 | out_class: | ||
446 | bus_unregister(&bt_bus); | ||
447 | out_bus: | ||
448 | platform_device_unregister(bt_platform); | ||
449 | out_platform: | ||
450 | destroy_workqueue(btdelconn); | ||
451 | out_del: | ||
452 | destroy_workqueue(btaddconn); | ||
453 | out: | ||
454 | return err; | ||
455 | } | 462 | } |
456 | 463 | ||
457 | void bt_sysfs_cleanup(void) | 464 | void bt_sysfs_cleanup(void) |
458 | { | 465 | { |
459 | destroy_workqueue(btaddconn); | 466 | destroy_workqueue(btaddconn); |
460 | |||
461 | destroy_workqueue(btdelconn); | 467 | destroy_workqueue(btdelconn); |
462 | 468 | ||
463 | class_destroy(bt_class); | 469 | class_destroy(bt_class); |
464 | |||
465 | bus_unregister(&bt_bus); | ||
466 | |||
467 | platform_device_unregister(bt_platform); | ||
468 | } | 470 | } |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index c1239852834a..3396d5bdef1c 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -2516,7 +2516,7 @@ EXPORT_SYMBOL(l2cap_load); | |||
2516 | module_init(l2cap_init); | 2516 | module_init(l2cap_init); |
2517 | module_exit(l2cap_exit); | 2517 | module_exit(l2cap_exit); |
2518 | 2518 | ||
2519 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 2519 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
2520 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); | 2520 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); |
2521 | MODULE_VERSION(VERSION); | 2521 | MODULE_VERSION(VERSION); |
2522 | MODULE_LICENSE("GPL"); | 2522 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 6cfc7ba611b3..ba537fae0a4c 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -2115,7 +2115,7 @@ MODULE_PARM_DESC(channel_mtu, "Default MTU for the RFCOMM channel"); | |||
2115 | module_param(l2cap_mtu, uint, 0644); | 2115 | module_param(l2cap_mtu, uint, 0644); |
2116 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); | 2116 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); |
2117 | 2117 | ||
2118 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 2118 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
2119 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); | 2119 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); |
2120 | MODULE_VERSION(VERSION); | 2120 | MODULE_VERSION(VERSION); |
2121 | MODULE_LICENSE("GPL"); | 2121 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 8cda49874868..a16011fedc1d 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -1002,7 +1002,7 @@ module_exit(sco_exit); | |||
1002 | module_param(disable_esco, bool, 0644); | 1002 | module_param(disable_esco, bool, 0644); |
1003 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); | 1003 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); |
1004 | 1004 | ||
1005 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 1005 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
1006 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); | 1006 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); |
1007 | MODULE_VERSION(VERSION); | 1007 | MODULE_VERSION(VERSION); |
1008 | MODULE_LICENSE("GPL"); | 1008 | MODULE_LICENSE("GPL"); |