Merge tag 'docs-for-linus' of git://git.lwn.net/linux-2.6
[firefly-linux-kernel-4.4.55.git] / net / bluetooth / hci_core.c
index 6192f6e3242ff5745df94f43f9d2973ce6298a47..476709bd068a474f7edcac83a4869849ccfb4b17 100644 (file)
@@ -166,53 +166,6 @@ static void hci_req_cancel(struct hci_dev *hdev, int err)
        }
 }
 
-static struct sk_buff *hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
-                                           u8 event, struct sk_buff *skb)
-{
-       struct hci_ev_cmd_complete *ev;
-       struct hci_event_hdr *hdr;
-
-       if (!skb)
-               return ERR_PTR(-ENODATA);
-
-       if (skb->len < sizeof(*hdr)) {
-               BT_ERR("Too short HCI event");
-               goto failed;
-       }
-
-       hdr = (void *) skb->data;
-       skb_pull(skb, HCI_EVENT_HDR_SIZE);
-
-       if (event) {
-               if (hdr->evt != event)
-                       goto failed;
-               return skb;
-       }
-
-       if (hdr->evt != HCI_EV_CMD_COMPLETE) {
-               BT_DBG("Last event is not cmd complete (0x%2.2x)", hdr->evt);
-               goto failed;
-       }
-
-       if (skb->len < sizeof(*ev)) {
-               BT_ERR("Too short cmd_complete event");
-               goto failed;
-       }
-
-       ev = (void *) skb->data;
-       skb_pull(skb, sizeof(*ev));
-
-       if (opcode == __le16_to_cpu(ev->opcode))
-               return skb;
-
-       BT_DBG("opcode doesn't match (0x%2.2x != 0x%2.2x)", opcode,
-              __le16_to_cpu(ev->opcode));
-
-failed:
-       kfree_skb(skb);
-       return ERR_PTR(-ENODATA);
-}
-
 struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
                                  const void *param, u8 event, u32 timeout)
 {
@@ -271,7 +224,10 @@ struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
                return ERR_PTR(err);
        }
 
-       return hci_get_cmd_complete(hdev, opcode, event, skb);
+       if (!skb)
+               return ERR_PTR(-ENODATA);
+
+       return skb;
 }
 EXPORT_SYMBOL(__hci_cmd_sync_ev);
 
@@ -3244,7 +3200,7 @@ EXPORT_SYMBOL(hci_register_dev);
 /* Unregister HCI device */
 void hci_unregister_dev(struct hci_dev *hdev)
 {
-       int i, id;
+       int id;
 
        BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
 
@@ -3258,9 +3214,6 @@ void hci_unregister_dev(struct hci_dev *hdev)
 
        hci_dev_do_close(hdev);
 
-       for (i = 0; i < NUM_REASSEMBLY; i++)
-               kfree_skb(hdev->reassembly[i]);
-
        cancel_work_sync(&hdev->power_on);
 
        if (!test_bit(HCI_INIT, &hdev->flags) &&
@@ -3364,149 +3317,6 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
 }
 EXPORT_SYMBOL(hci_recv_frame);
 
-static int hci_reassembly(struct hci_dev *hdev, int type, void *data,
-                         int count, __u8 index)
-{
-       int len = 0;
-       int hlen = 0;
-       int remain = count;
-       struct sk_buff *skb;
-       struct bt_skb_cb *scb;
-
-       if ((type < HCI_ACLDATA_PKT || type > HCI_EVENT_PKT) ||
-           index >= NUM_REASSEMBLY)
-               return -EILSEQ;
-
-       skb = hdev->reassembly[index];
-
-       if (!skb) {
-               switch (type) {
-               case HCI_ACLDATA_PKT:
-                       len = HCI_MAX_FRAME_SIZE;
-                       hlen = HCI_ACL_HDR_SIZE;
-                       break;
-               case HCI_EVENT_PKT:
-                       len = HCI_MAX_EVENT_SIZE;
-                       hlen = HCI_EVENT_HDR_SIZE;
-                       break;
-               case HCI_SCODATA_PKT:
-                       len = HCI_MAX_SCO_SIZE;
-                       hlen = HCI_SCO_HDR_SIZE;
-                       break;
-               }
-
-               skb = bt_skb_alloc(len, GFP_ATOMIC);
-               if (!skb)
-                       return -ENOMEM;
-
-               scb = (void *) skb->cb;
-               scb->expect = hlen;
-               scb->pkt_type = type;
-
-               hdev->reassembly[index] = skb;
-       }
-
-       while (count) {
-               scb = (void *) skb->cb;
-               len = min_t(uint, scb->expect, count);
-
-               memcpy(skb_put(skb, len), data, len);
-
-               count -= len;
-               data += len;
-               scb->expect -= len;
-               remain = count;
-
-               switch (type) {
-               case HCI_EVENT_PKT:
-                       if (skb->len == HCI_EVENT_HDR_SIZE) {
-                               struct hci_event_hdr *h = hci_event_hdr(skb);
-                               scb->expect = h->plen;
-
-                               if (skb_tailroom(skb) < scb->expect) {
-                                       kfree_skb(skb);
-                                       hdev->reassembly[index] = NULL;
-                                       return -ENOMEM;
-                               }
-                       }
-                       break;
-
-               case HCI_ACLDATA_PKT:
-                       if (skb->len  == HCI_ACL_HDR_SIZE) {
-                               struct hci_acl_hdr *h = hci_acl_hdr(skb);
-                               scb->expect = __le16_to_cpu(h->dlen);
-
-                               if (skb_tailroom(skb) < scb->expect) {
-                                       kfree_skb(skb);
-                                       hdev->reassembly[index] = NULL;
-                                       return -ENOMEM;
-                               }
-                       }
-                       break;
-
-               case HCI_SCODATA_PKT:
-                       if (skb->len == HCI_SCO_HDR_SIZE) {
-                               struct hci_sco_hdr *h = hci_sco_hdr(skb);
-                               scb->expect = h->dlen;
-
-                               if (skb_tailroom(skb) < scb->expect) {
-                                       kfree_skb(skb);
-                                       hdev->reassembly[index] = NULL;
-                                       return -ENOMEM;
-                               }
-                       }
-                       break;
-               }
-
-               if (scb->expect == 0) {
-                       /* Complete frame */
-
-                       bt_cb(skb)->pkt_type = type;
-                       hci_recv_frame(hdev, skb);
-
-                       hdev->reassembly[index] = NULL;
-                       return remain;
-               }
-       }
-
-       return remain;
-}
-
-#define STREAM_REASSEMBLY 0
-
-int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count)
-{
-       int type;
-       int rem = 0;
-
-       while (count) {
-               struct sk_buff *skb = hdev->reassembly[STREAM_REASSEMBLY];
-
-               if (!skb) {
-                       struct { char type; } *pkt;
-
-                       /* Start of the frame */
-                       pkt = data;
-                       type = pkt->type;
-
-                       data++;
-                       count--;
-               } else
-                       type = bt_cb(skb)->pkt_type;
-
-               rem = hci_reassembly(hdev, type, data, count,
-                                    STREAM_REASSEMBLY);
-               if (rem < 0)
-                       return rem;
-
-               data += (count - rem);
-               count = rem;
-       }
-
-       return rem;
-}
-EXPORT_SYMBOL(hci_recv_stream_fragment);
-
 /* ---- Interface to upper protocols ---- */
 
 int hci_register_cb(struct hci_cb *cb)
@@ -3560,11 +3370,6 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
        }
 }
 
-bool hci_req_pending(struct hci_dev *hdev)
-{
-       return (hdev->req_status == HCI_REQ_PEND);
-}
-
 /* Send HCI command */
 int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
                 const void *param)