Bluetooth: add hci_lookup_le_connect
[firefly-linux-kernel-4.4.55.git] / include / net / bluetooth / hci_core.h
index c8d2b5a89d08169da30730acbfd34c2dc4fc42fc..f0a9fc1d06e094598f9ddbb44ea5c6fa98539d19 100644 (file)
@@ -811,6 +811,26 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
        return NULL;
 }
 
+static inline struct hci_conn *hci_lookup_le_connect(struct hci_dev *hdev)
+{
+       struct hci_conn_hash *h = &hdev->conn_hash;
+       struct hci_conn  *c;
+
+       rcu_read_lock();
+
+       list_for_each_entry_rcu(c, &h->list, list) {
+               if (c->type == LE_LINK && c->state == BT_CONNECT &&
+                   !test_bit(HCI_CONN_SCANNING, &c->flags)) {
+                       rcu_read_unlock();
+                       return c;
+               }
+       }
+
+       rcu_read_unlock();
+
+       return NULL;
+}
+
 int hci_disconnect(struct hci_conn *conn, __u8 reason);
 bool hci_setup_sync(struct hci_conn *conn, __u16 handle);
 void hci_sco_setup(struct hci_conn *conn, __u8 status);