aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h3
-rw-r--r--net/bluetooth/hci_conn.c32
2 files changed, 34 insertions, 1 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index dfa108c4abec..b697ef342020 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -350,7 +350,7 @@ struct hci_conn {
350 350
351struct hci_chan { 351struct hci_chan {
352 struct list_head list; 352 struct list_head list;
353 353 __u16 handle;
354 struct hci_conn *conn; 354 struct hci_conn *conn;
355 struct sk_buff_head data_q; 355 struct sk_buff_head data_q;
356 unsigned int sent; 356 unsigned int sent;
@@ -567,6 +567,7 @@ void hci_conn_check_pending(struct hci_dev *hdev);
567struct hci_chan *hci_chan_create(struct hci_conn *conn); 567struct hci_chan *hci_chan_create(struct hci_conn *conn);
568void hci_chan_del(struct hci_chan *chan); 568void hci_chan_del(struct hci_chan *chan);
569void hci_chan_list_flush(struct hci_conn *conn); 569void hci_chan_list_flush(struct hci_conn *conn);
570struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle);
570 571
571struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, 572struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
572 __u8 dst_type, __u8 sec_level, __u8 auth_type); 573 __u8 dst_type, __u8 sec_level, __u8 auth_type);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 64875794dd9b..fe646211c61f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -989,3 +989,35 @@ void hci_chan_list_flush(struct hci_conn *conn)
989 list_for_each_entry_safe(chan, n, &conn->chan_list, list) 989 list_for_each_entry_safe(chan, n, &conn->chan_list, list)
990 hci_chan_del(chan); 990 hci_chan_del(chan);
991} 991}
992
993static struct hci_chan *__hci_chan_lookup_handle(struct hci_conn *hcon,
994 __u16 handle)
995{
996 struct hci_chan *hchan;
997
998 list_for_each_entry(hchan, &hcon->chan_list, list) {
999 if (hchan->handle == handle)
1000 return hchan;
1001 }
1002
1003 return NULL;
1004}
1005
1006struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle)
1007{
1008 struct hci_conn_hash *h = &hdev->conn_hash;
1009 struct hci_conn *hcon;
1010 struct hci_chan *hchan = NULL;
1011
1012 rcu_read_lock();
1013
1014 list_for_each_entry_rcu(hcon, &h->list, list) {
1015 hchan = __hci_chan_lookup_handle(hcon, handle);
1016 if (hchan)
1017 break;
1018 }
1019
1020 rcu_read_unlock();
1021
1022 return hchan;
1023}