diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2015-02-18 07:53:57 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-02-19 02:44:29 -0500 |
commit | 539c496d88f7f96d42abde4e9d901c8f8167d615 (patch) | |
tree | b46fdad2015a84dc049766ae31f893e974a08c6a /net/bluetooth | |
parent | 354fe804edb29625eee6dd7b1f3c72b43392704d (diff) |
Bluetooth: Convert connect_cfm to be triggered through hci_cb
This patch moves all the connect_cfm callbacks to be based on the hci_cb
list. This means making l2cap_connect_cfm private to l2cap_core.c and
sco_connect_cb private to sco.c respectively. Since the hci_conn type
filtering isn't done any more on the wrapper level the callbacks
themselves need to check that they were passed a relevant type of
connection.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_conn.c | 4 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 36 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/sco.c | 15 |
4 files changed, 39 insertions, 22 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index e3263b61bcf3..e9206734e024 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -309,7 +309,7 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status) | |||
309 | else | 309 | else |
310 | hci_add_sco(sco, conn->handle); | 310 | hci_add_sco(sco, conn->handle); |
311 | } else { | 311 | } else { |
312 | hci_proto_connect_cfm(sco, status); | 312 | hci_connect_cfm(sco, status); |
313 | hci_conn_del(sco); | 313 | hci_conn_del(sco); |
314 | } | 314 | } |
315 | } | 315 | } |
@@ -618,7 +618,7 @@ void hci_le_conn_failed(struct hci_conn *conn, u8 status) | |||
618 | mgmt_connect_failed(hdev, &conn->dst, conn->type, conn->dst_type, | 618 | mgmt_connect_failed(hdev, &conn->dst, conn->type, conn->dst_type, |
619 | status); | 619 | status); |
620 | 620 | ||
621 | hci_proto_connect_cfm(conn, status); | 621 | hci_connect_cfm(conn, status); |
622 | 622 | ||
623 | hci_conn_del(conn); | 623 | hci_conn_del(conn); |
624 | 624 | ||
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a3fb094822b6..0b599129c64c 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1537,7 +1537,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) | |||
1537 | if (conn && conn->state == BT_CONNECT) { | 1537 | if (conn && conn->state == BT_CONNECT) { |
1538 | if (status != 0x0c || conn->attempt > 2) { | 1538 | if (status != 0x0c || conn->attempt > 2) { |
1539 | conn->state = BT_CLOSED; | 1539 | conn->state = BT_CLOSED; |
1540 | hci_proto_connect_cfm(conn, status); | 1540 | hci_connect_cfm(conn, status); |
1541 | hci_conn_del(conn); | 1541 | hci_conn_del(conn); |
1542 | } else | 1542 | } else |
1543 | conn->state = BT_CONNECT2; | 1543 | conn->state = BT_CONNECT2; |
@@ -1581,7 +1581,7 @@ static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status) | |||
1581 | if (sco) { | 1581 | if (sco) { |
1582 | sco->state = BT_CLOSED; | 1582 | sco->state = BT_CLOSED; |
1583 | 1583 | ||
1584 | hci_proto_connect_cfm(sco, status); | 1584 | hci_connect_cfm(sco, status); |
1585 | hci_conn_del(sco); | 1585 | hci_conn_del(sco); |
1586 | } | 1586 | } |
1587 | } | 1587 | } |
@@ -1608,7 +1608,7 @@ static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status) | |||
1608 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); | 1608 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); |
1609 | if (conn) { | 1609 | if (conn) { |
1610 | if (conn->state == BT_CONFIG) { | 1610 | if (conn->state == BT_CONFIG) { |
1611 | hci_proto_connect_cfm(conn, status); | 1611 | hci_connect_cfm(conn, status); |
1612 | hci_conn_drop(conn); | 1612 | hci_conn_drop(conn); |
1613 | } | 1613 | } |
1614 | } | 1614 | } |
@@ -1635,7 +1635,7 @@ static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status) | |||
1635 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); | 1635 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); |
1636 | if (conn) { | 1636 | if (conn) { |
1637 | if (conn->state == BT_CONFIG) { | 1637 | if (conn->state == BT_CONFIG) { |
1638 | hci_proto_connect_cfm(conn, status); | 1638 | hci_connect_cfm(conn, status); |
1639 | hci_conn_drop(conn); | 1639 | hci_conn_drop(conn); |
1640 | } | 1640 | } |
1641 | } | 1641 | } |
@@ -1811,7 +1811,7 @@ static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status) | |||
1811 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); | 1811 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); |
1812 | if (conn) { | 1812 | if (conn) { |
1813 | if (conn->state == BT_CONFIG) { | 1813 | if (conn->state == BT_CONFIG) { |
1814 | hci_proto_connect_cfm(conn, status); | 1814 | hci_connect_cfm(conn, status); |
1815 | hci_conn_drop(conn); | 1815 | hci_conn_drop(conn); |
1816 | } | 1816 | } |
1817 | } | 1817 | } |
@@ -1838,7 +1838,7 @@ static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status) | |||
1838 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); | 1838 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); |
1839 | if (conn) { | 1839 | if (conn) { |
1840 | if (conn->state == BT_CONFIG) { | 1840 | if (conn->state == BT_CONFIG) { |
1841 | hci_proto_connect_cfm(conn, status); | 1841 | hci_connect_cfm(conn, status); |
1842 | hci_conn_drop(conn); | 1842 | hci_conn_drop(conn); |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
@@ -1873,7 +1873,7 @@ static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status) | |||
1873 | if (sco) { | 1873 | if (sco) { |
1874 | sco->state = BT_CLOSED; | 1874 | sco->state = BT_CLOSED; |
1875 | 1875 | ||
1876 | hci_proto_connect_cfm(sco, status); | 1876 | hci_connect_cfm(sco, status); |
1877 | hci_conn_del(sco); | 1877 | hci_conn_del(sco); |
1878 | } | 1878 | } |
1879 | } | 1879 | } |
@@ -2255,10 +2255,10 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2255 | hci_sco_setup(conn, ev->status); | 2255 | hci_sco_setup(conn, ev->status); |
2256 | 2256 | ||
2257 | if (ev->status) { | 2257 | if (ev->status) { |
2258 | hci_proto_connect_cfm(conn, ev->status); | 2258 | hci_connect_cfm(conn, ev->status); |
2259 | hci_conn_del(conn); | 2259 | hci_conn_del(conn); |
2260 | } else if (ev->link_type != ACL_LINK) | 2260 | } else if (ev->link_type != ACL_LINK) |
2261 | hci_proto_connect_cfm(conn, ev->status); | 2261 | hci_connect_cfm(conn, ev->status); |
2262 | 2262 | ||
2263 | unlock: | 2263 | unlock: |
2264 | hci_dev_unlock(hdev); | 2264 | hci_dev_unlock(hdev); |
@@ -2366,7 +2366,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2366 | &cp); | 2366 | &cp); |
2367 | } else { | 2367 | } else { |
2368 | conn->state = BT_CONNECT2; | 2368 | conn->state = BT_CONNECT2; |
2369 | hci_proto_connect_cfm(conn, 0); | 2369 | hci_connect_cfm(conn, 0); |
2370 | } | 2370 | } |
2371 | } | 2371 | } |
2372 | 2372 | ||
@@ -2501,7 +2501,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2501 | &cp); | 2501 | &cp); |
2502 | } else { | 2502 | } else { |
2503 | conn->state = BT_CONNECTED; | 2503 | conn->state = BT_CONNECTED; |
2504 | hci_proto_connect_cfm(conn, ev->status); | 2504 | hci_connect_cfm(conn, ev->status); |
2505 | hci_conn_drop(conn); | 2505 | hci_conn_drop(conn); |
2506 | } | 2506 | } |
2507 | } else { | 2507 | } else { |
@@ -2629,12 +2629,12 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2629 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags) && | 2629 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags) && |
2630 | (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || | 2630 | (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || |
2631 | conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { | 2631 | conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { |
2632 | hci_proto_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); | 2632 | hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); |
2633 | hci_conn_drop(conn); | 2633 | hci_conn_drop(conn); |
2634 | goto unlock; | 2634 | goto unlock; |
2635 | } | 2635 | } |
2636 | 2636 | ||
2637 | hci_proto_connect_cfm(conn, ev->status); | 2637 | hci_connect_cfm(conn, ev->status); |
2638 | hci_conn_drop(conn); | 2638 | hci_conn_drop(conn); |
2639 | } else | 2639 | } else |
2640 | hci_encrypt_cfm(conn, ev->status, ev->encrypt); | 2640 | hci_encrypt_cfm(conn, ev->status, ev->encrypt); |
@@ -2707,7 +2707,7 @@ static void hci_remote_features_evt(struct hci_dev *hdev, | |||
2707 | 2707 | ||
2708 | if (!hci_outgoing_auth_needed(hdev, conn)) { | 2708 | if (!hci_outgoing_auth_needed(hdev, conn)) { |
2709 | conn->state = BT_CONNECTED; | 2709 | conn->state = BT_CONNECTED; |
2710 | hci_proto_connect_cfm(conn, ev->status); | 2710 | hci_connect_cfm(conn, ev->status); |
2711 | hci_conn_drop(conn); | 2711 | hci_conn_drop(conn); |
2712 | } | 2712 | } |
2713 | 2713 | ||
@@ -3679,7 +3679,7 @@ static void hci_remote_ext_features_evt(struct hci_dev *hdev, | |||
3679 | 3679 | ||
3680 | if (!hci_outgoing_auth_needed(hdev, conn)) { | 3680 | if (!hci_outgoing_auth_needed(hdev, conn)) { |
3681 | conn->state = BT_CONNECTED; | 3681 | conn->state = BT_CONNECTED; |
3682 | hci_proto_connect_cfm(conn, ev->status); | 3682 | hci_connect_cfm(conn, ev->status); |
3683 | hci_conn_drop(conn); | 3683 | hci_conn_drop(conn); |
3684 | } | 3684 | } |
3685 | 3685 | ||
@@ -3738,7 +3738,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, | |||
3738 | break; | 3738 | break; |
3739 | } | 3739 | } |
3740 | 3740 | ||
3741 | hci_proto_connect_cfm(conn, ev->status); | 3741 | hci_connect_cfm(conn, ev->status); |
3742 | if (ev->status) | 3742 | if (ev->status) |
3743 | hci_conn_del(conn); | 3743 | hci_conn_del(conn); |
3744 | 3744 | ||
@@ -3849,7 +3849,7 @@ static void hci_key_refresh_complete_evt(struct hci_dev *hdev, | |||
3849 | if (!ev->status) | 3849 | if (!ev->status) |
3850 | conn->state = BT_CONNECTED; | 3850 | conn->state = BT_CONNECTED; |
3851 | 3851 | ||
3852 | hci_proto_connect_cfm(conn, ev->status); | 3852 | hci_connect_cfm(conn, ev->status); |
3853 | hci_conn_drop(conn); | 3853 | hci_conn_drop(conn); |
3854 | } else { | 3854 | } else { |
3855 | hci_auth_cfm(conn, ev->status); | 3855 | hci_auth_cfm(conn, ev->status); |
@@ -4512,7 +4512,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4512 | hci_debugfs_create_conn(conn); | 4512 | hci_debugfs_create_conn(conn); |
4513 | hci_conn_add_sysfs(conn); | 4513 | hci_conn_add_sysfs(conn); |
4514 | 4514 | ||
4515 | hci_proto_connect_cfm(conn, ev->status); | 4515 | hci_connect_cfm(conn, ev->status); |
4516 | 4516 | ||
4517 | params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, | 4517 | params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, |
4518 | conn->dst_type); | 4518 | conn->dst_type); |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 424fcc5c4980..6e2c3bdda7d3 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -7252,13 +7252,16 @@ static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c, | |||
7252 | return NULL; | 7252 | return NULL; |
7253 | } | 7253 | } |
7254 | 7254 | ||
7255 | void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) | 7255 | static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) |
7256 | { | 7256 | { |
7257 | struct hci_dev *hdev = hcon->hdev; | 7257 | struct hci_dev *hdev = hcon->hdev; |
7258 | struct l2cap_conn *conn; | 7258 | struct l2cap_conn *conn; |
7259 | struct l2cap_chan *pchan; | 7259 | struct l2cap_chan *pchan; |
7260 | u8 dst_type; | 7260 | u8 dst_type; |
7261 | 7261 | ||
7262 | if (hcon->type != ACL_LINK && hcon->type != LE_LINK) | ||
7263 | return; | ||
7264 | |||
7262 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); | 7265 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); |
7263 | 7266 | ||
7264 | if (status) { | 7267 | if (status) { |
@@ -7543,6 +7546,7 @@ drop: | |||
7543 | 7546 | ||
7544 | static struct hci_cb l2cap_cb = { | 7547 | static struct hci_cb l2cap_cb = { |
7545 | .name = "L2CAP", | 7548 | .name = "L2CAP", |
7549 | .connect_cfm = l2cap_connect_cfm, | ||
7546 | .security_cfm = l2cap_security_cfm, | 7550 | .security_cfm = l2cap_security_cfm, |
7547 | }; | 7551 | }; |
7548 | 7552 | ||
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 76321b546e84..3c2e36f94b65 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -1083,9 +1083,13 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags) | |||
1083 | return lm; | 1083 | return lm; |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | void sco_connect_cfm(struct hci_conn *hcon, __u8 status) | 1086 | static void sco_connect_cfm(struct hci_conn *hcon, __u8 status) |
1087 | { | 1087 | { |
1088 | if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) | ||
1089 | return; | ||
1090 | |||
1088 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); | 1091 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); |
1092 | |||
1089 | if (!status) { | 1093 | if (!status) { |
1090 | struct sco_conn *conn; | 1094 | struct sco_conn *conn; |
1091 | 1095 | ||
@@ -1122,6 +1126,11 @@ drop: | |||
1122 | return 0; | 1126 | return 0; |
1123 | } | 1127 | } |
1124 | 1128 | ||
1129 | static struct hci_cb sco_cb = { | ||
1130 | .name = "SCO", | ||
1131 | .connect_cfm = sco_connect_cfm, | ||
1132 | }; | ||
1133 | |||
1125 | static int sco_debugfs_show(struct seq_file *f, void *p) | 1134 | static int sco_debugfs_show(struct seq_file *f, void *p) |
1126 | { | 1135 | { |
1127 | struct sock *sk; | 1136 | struct sock *sk; |
@@ -1203,6 +1212,8 @@ int __init sco_init(void) | |||
1203 | 1212 | ||
1204 | BT_INFO("SCO socket layer initialized"); | 1213 | BT_INFO("SCO socket layer initialized"); |
1205 | 1214 | ||
1215 | hci_register_cb(&sco_cb); | ||
1216 | |||
1206 | if (IS_ERR_OR_NULL(bt_debugfs)) | 1217 | if (IS_ERR_OR_NULL(bt_debugfs)) |
1207 | return 0; | 1218 | return 0; |
1208 | 1219 | ||
@@ -1222,6 +1233,8 @@ void __exit sco_exit(void) | |||
1222 | 1233 | ||
1223 | debugfs_remove(sco_debugfs); | 1234 | debugfs_remove(sco_debugfs); |
1224 | 1235 | ||
1236 | hci_unregister_cb(&sco_cb); | ||
1237 | |||
1225 | bt_sock_unregister(BTPROTO_SCO); | 1238 | bt_sock_unregister(BTPROTO_SCO); |
1226 | 1239 | ||
1227 | proto_unregister(&sco_proto); | 1240 | proto_unregister(&sco_proto); |