Bluetooth: Introduce LE auto connect options
[pandora-kernel.git] / net / bluetooth / hci_event.c
index b6631d7..46da8b6 100644 (file)
@@ -1841,6 +1841,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
        struct hci_ev_disconn_complete *ev = (void *) skb->data;
        u8 reason = hci_to_mgmt_reason(ev->reason);
+       struct hci_conn_params *params;
        struct hci_conn *conn;
        bool mgmt_connected;
        u8 type;
@@ -1868,6 +1869,23 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
        if (conn->type == ACL_LINK && conn->flush_key)
                hci_remove_link_key(hdev, &conn->dst);
 
+       params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
+       if (params) {
+               switch (params->auto_connect) {
+               case HCI_AUTO_CONN_LINK_LOSS:
+                       if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT)
+                               break;
+                       /* Fall through */
+
+               case HCI_AUTO_CONN_ALWAYS:
+                       hci_pend_le_conn_add(hdev, &conn->dst, conn->dst_type);
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
        type = conn->type;
 
        hci_proto_disconn_cfm(conn, ev->reason);