Bluetooth: Disconnect logical link when deleting chan
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Wed, 31 Oct 2012 13:46:34 +0000 (15:46 +0200)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Thu, 1 Nov 2012 22:27:09 +0000 (20:27 -0200)
Disconnect logical link for high speed channel hs_hchan
associated with L2CAP channel chan.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
include/net/bluetooth/amp.h
net/bluetooth/amp.c
net/bluetooth/l2cap_core.c

index 405fb9c987effa9d98ef51ee1832dddaf6931d5a..f1c0017f69e7b0c5b290232d10b214002e6b729a 100644 (file)
@@ -47,6 +47,7 @@ void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
 void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle);
 void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle);
 void amp_create_logical_link(struct l2cap_chan *chan);
+void amp_disconnect_logical_link(struct hci_chan *hchan);
 void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason);
 
 #endif /* __AMP_H */
index 0f3fef34eabc462ff9552bb3fa64eb5f6dd23b0b..917e034b9aa5332972b988af99f0e73aa0daebb4 100644 (file)
@@ -422,6 +422,20 @@ done:
        hci_dev_put(hdev);
 }
 
+void amp_disconnect_logical_link(struct hci_chan *hchan)
+{
+       struct hci_conn *hcon = hchan->conn;
+       struct hci_cp_disconn_logical_link cp;
+
+       if (hcon->state != BT_CONNECTED) {
+               BT_DBG("hchan %p not connected", hchan);
+               return;
+       }
+
+       cp.log_handle = cpu_to_le16(hchan->handle);
+       hci_send_cmd(hcon->hdev, HCI_OP_DISCONN_LOGICAL_LINK, sizeof(cp), &cp);
+}
+
 void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason)
 {
        BT_DBG("hchan %p", hchan);
index ecc5020c924241693170626f91c518e1a601fb3d..bb2cd9eaa8a1ca19e5d89413c770775b446cdd1c 100644 (file)
@@ -578,6 +578,13 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
                        mgr->bredr_chan = NULL;
        }
 
+       if (chan->hs_hchan) {
+               struct hci_chan *hs_hchan = chan->hs_hchan;
+
+               BT_DBG("chan %p disconnect hs_hchan %p", chan, hs_hchan);
+               amp_disconnect_logical_link(hs_hchan);
+       }
+
        chan->ops->teardown(chan, err);
 
        if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))