diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-07-11 00:42:35 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-07-11 00:42:35 -0400 |
commit | babf4d42d0a41ff58463b0a0515683cdce66f541 (patch) | |
tree | 690c1e0a2e06bad2e16a4ab87221b6d63bc9e3da /drivers/bluetooth | |
parent | ef222013fc8c1a2fcba5c7ab169be8ffcb778ec4 (diff) |
[Bluetooth] Use hci_recv_fragment() within HCI USB driver
This patch modifies the HCI USB driver to use the new helper function
for reassembling HCI data packets and events.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/hci_usb.c | 88 | ||||
-rw-r--r-- | drivers/bluetooth/hci_usb.h | 5 |
2 files changed, 4 insertions, 89 deletions
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 7e04dd69f609..59b054810ed0 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c | |||
@@ -199,7 +199,6 @@ static void hci_usb_tx_complete(struct urb *urb); | |||
199 | #define __pending_q(husb, type) (&husb->pending_q[type-1]) | 199 | #define __pending_q(husb, type) (&husb->pending_q[type-1]) |
200 | #define __completed_q(husb, type) (&husb->completed_q[type-1]) | 200 | #define __completed_q(husb, type) (&husb->completed_q[type-1]) |
201 | #define __transmit_q(husb, type) (&husb->transmit_q[type-1]) | 201 | #define __transmit_q(husb, type) (&husb->transmit_q[type-1]) |
202 | #define __reassembly(husb, type) (husb->reassembly[type-1]) | ||
203 | 202 | ||
204 | static inline struct _urb *__get_completed(struct hci_usb *husb, int type) | 203 | static inline struct _urb *__get_completed(struct hci_usb *husb, int type) |
205 | { | 204 | { |
@@ -429,12 +428,6 @@ static void hci_usb_unlink_urbs(struct hci_usb *husb) | |||
429 | kfree(urb->transfer_buffer); | 428 | kfree(urb->transfer_buffer); |
430 | _urb_free(_urb); | 429 | _urb_free(_urb); |
431 | } | 430 | } |
432 | |||
433 | /* Release reassembly buffers */ | ||
434 | if (husb->reassembly[i]) { | ||
435 | kfree_skb(husb->reassembly[i]); | ||
436 | husb->reassembly[i] = NULL; | ||
437 | } | ||
438 | } | 431 | } |
439 | } | 432 | } |
440 | 433 | ||
@@ -671,83 +664,6 @@ static int hci_usb_send_frame(struct sk_buff *skb) | |||
671 | return 0; | 664 | return 0; |
672 | } | 665 | } |
673 | 666 | ||
674 | static inline int __recv_frame(struct hci_usb *husb, int type, void *data, int count) | ||
675 | { | ||
676 | BT_DBG("%s type %d data %p count %d", husb->hdev->name, type, data, count); | ||
677 | |||
678 | husb->hdev->stat.byte_rx += count; | ||
679 | |||
680 | while (count) { | ||
681 | struct sk_buff *skb = __reassembly(husb, type); | ||
682 | struct { int expect; } *scb; | ||
683 | int len = 0; | ||
684 | |||
685 | if (!skb) { | ||
686 | /* Start of the frame */ | ||
687 | |||
688 | switch (type) { | ||
689 | case HCI_EVENT_PKT: | ||
690 | if (count >= HCI_EVENT_HDR_SIZE) { | ||
691 | struct hci_event_hdr *h = data; | ||
692 | len = HCI_EVENT_HDR_SIZE + h->plen; | ||
693 | } else | ||
694 | return -EILSEQ; | ||
695 | break; | ||
696 | |||
697 | case HCI_ACLDATA_PKT: | ||
698 | if (count >= HCI_ACL_HDR_SIZE) { | ||
699 | struct hci_acl_hdr *h = data; | ||
700 | len = HCI_ACL_HDR_SIZE + __le16_to_cpu(h->dlen); | ||
701 | } else | ||
702 | return -EILSEQ; | ||
703 | break; | ||
704 | #ifdef CONFIG_BT_HCIUSB_SCO | ||
705 | case HCI_SCODATA_PKT: | ||
706 | if (count >= HCI_SCO_HDR_SIZE) { | ||
707 | struct hci_sco_hdr *h = data; | ||
708 | len = HCI_SCO_HDR_SIZE + h->dlen; | ||
709 | } else | ||
710 | return -EILSEQ; | ||
711 | break; | ||
712 | #endif | ||
713 | } | ||
714 | BT_DBG("new packet len %d", len); | ||
715 | |||
716 | skb = bt_skb_alloc(len, GFP_ATOMIC); | ||
717 | if (!skb) { | ||
718 | BT_ERR("%s no memory for the packet", husb->hdev->name); | ||
719 | return -ENOMEM; | ||
720 | } | ||
721 | skb->dev = (void *) husb->hdev; | ||
722 | bt_cb(skb)->pkt_type = type; | ||
723 | |||
724 | __reassembly(husb, type) = skb; | ||
725 | |||
726 | scb = (void *) skb->cb; | ||
727 | scb->expect = len; | ||
728 | } else { | ||
729 | /* Continuation */ | ||
730 | scb = (void *) skb->cb; | ||
731 | len = scb->expect; | ||
732 | } | ||
733 | |||
734 | len = min(len, count); | ||
735 | |||
736 | memcpy(skb_put(skb, len), data, len); | ||
737 | |||
738 | scb->expect -= len; | ||
739 | if (!scb->expect) { | ||
740 | /* Complete frame */ | ||
741 | __reassembly(husb, type) = NULL; | ||
742 | bt_cb(skb)->pkt_type = type; | ||
743 | hci_recv_frame(skb); | ||
744 | } | ||
745 | |||
746 | count -= len; data += len; | ||
747 | } | ||
748 | return 0; | ||
749 | } | ||
750 | |||
751 | static void hci_usb_rx_complete(struct urb *urb) | 667 | static void hci_usb_rx_complete(struct urb *urb) |
752 | { | 668 | { |
753 | struct _urb *_urb = container_of(urb, struct _urb, urb); | 669 | struct _urb *_urb = container_of(urb, struct _urb, urb); |
@@ -776,7 +692,7 @@ static void hci_usb_rx_complete(struct urb *urb) | |||
776 | urb->iso_frame_desc[i].actual_length); | 692 | urb->iso_frame_desc[i].actual_length); |
777 | 693 | ||
778 | if (!urb->iso_frame_desc[i].status) | 694 | if (!urb->iso_frame_desc[i].status) |
779 | __recv_frame(husb, _urb->type, | 695 | hci_recv_fragment(husb->hdev, _urb->type, |
780 | urb->transfer_buffer + urb->iso_frame_desc[i].offset, | 696 | urb->transfer_buffer + urb->iso_frame_desc[i].offset, |
781 | urb->iso_frame_desc[i].actual_length); | 697 | urb->iso_frame_desc[i].actual_length); |
782 | } | 698 | } |
@@ -784,7 +700,7 @@ static void hci_usb_rx_complete(struct urb *urb) | |||
784 | ; | 700 | ; |
785 | #endif | 701 | #endif |
786 | } else { | 702 | } else { |
787 | err = __recv_frame(husb, _urb->type, urb->transfer_buffer, count); | 703 | err = hci_recv_fragment(husb->hdev, _urb->type, urb->transfer_buffer, count); |
788 | if (err < 0) { | 704 | if (err < 0) { |
789 | BT_ERR("%s corrupted packet: type %d count %d", | 705 | BT_ERR("%s corrupted packet: type %d count %d", |
790 | husb->hdev->name, _urb->type, count); | 706 | husb->hdev->name, _urb->type, count); |
diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h index 963fc55cdc85..56cd3a92ceca 100644 --- a/drivers/bluetooth/hci_usb.h +++ b/drivers/bluetooth/hci_usb.h | |||
@@ -102,9 +102,9 @@ struct hci_usb { | |||
102 | struct hci_dev *hdev; | 102 | struct hci_dev *hdev; |
103 | 103 | ||
104 | unsigned long state; | 104 | unsigned long state; |
105 | 105 | ||
106 | struct usb_device *udev; | 106 | struct usb_device *udev; |
107 | 107 | ||
108 | struct usb_host_endpoint *bulk_in_ep; | 108 | struct usb_host_endpoint *bulk_in_ep; |
109 | struct usb_host_endpoint *bulk_out_ep; | 109 | struct usb_host_endpoint *bulk_out_ep; |
110 | struct usb_host_endpoint *intr_in_ep; | 110 | struct usb_host_endpoint *intr_in_ep; |
@@ -116,7 +116,6 @@ struct hci_usb { | |||
116 | __u8 ctrl_req; | 116 | __u8 ctrl_req; |
117 | 117 | ||
118 | struct sk_buff_head transmit_q[4]; | 118 | struct sk_buff_head transmit_q[4]; |
119 | struct sk_buff *reassembly[4]; /* Reassembly buffers */ | ||
120 | 119 | ||
121 | rwlock_t completion_lock; | 120 | rwlock_t completion_lock; |
122 | 121 | ||