aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_event.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-04-06 14:28:37 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-04-11 15:34:15 -0400
commit76a68ba0ae097be72dfa8f918b3139130da769a4 (patch)
tree4a24ee83a895cfe49a23042989949e8b20d16deb /net/bluetooth/hci_event.c
parent9f8f962c85461324d18dcb2b1b94a932494d2cc5 (diff)
Bluetooth: rename hci_conn_put to hci_conn_drop
We use _get() and _put() for device ref-counting in the kernel. However, hci_conn_put() is _not_ used for ref-counting, hence, rename it to hci_conn_drop() so we can later fix ref-counting and introduce hci_conn_put(). hci_conn_hold() and hci_conn_put() are currently used to manage how long a connection should be held alive. When the last user drops the connection, we spawn a delayed work that performs the disconnect. Obviously, this has nothing to do with ref-counting for the _object_ but rather for the keep-alive of the connection. But we really _need_ proper ref-counting for the _object_ to allow connection-users like rfcomm-tty, HIDP or others. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r--net/bluetooth/hci_event.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 0a2b128d2cc9..2cf28b198b31 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1190,7 +1190,7 @@ static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status)
1190 if (conn) { 1190 if (conn) {
1191 if (conn->state == BT_CONFIG) { 1191 if (conn->state == BT_CONFIG) {
1192 hci_proto_connect_cfm(conn, status); 1192 hci_proto_connect_cfm(conn, status);
1193 hci_conn_put(conn); 1193 hci_conn_drop(conn);
1194 } 1194 }
1195 } 1195 }
1196 1196
@@ -1217,7 +1217,7 @@ static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status)
1217 if (conn) { 1217 if (conn) {
1218 if (conn->state == BT_CONFIG) { 1218 if (conn->state == BT_CONFIG) {
1219 hci_proto_connect_cfm(conn, status); 1219 hci_proto_connect_cfm(conn, status);
1220 hci_conn_put(conn); 1220 hci_conn_drop(conn);
1221 } 1221 }
1222 } 1222 }
1223 1223
@@ -1379,7 +1379,7 @@ static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status)
1379 if (conn) { 1379 if (conn) {
1380 if (conn->state == BT_CONFIG) { 1380 if (conn->state == BT_CONFIG) {
1381 hci_proto_connect_cfm(conn, status); 1381 hci_proto_connect_cfm(conn, status);
1382 hci_conn_put(conn); 1382 hci_conn_drop(conn);
1383 } 1383 }
1384 } 1384 }
1385 1385
@@ -1406,7 +1406,7 @@ static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status)
1406 if (conn) { 1406 if (conn) {
1407 if (conn->state == BT_CONFIG) { 1407 if (conn->state == BT_CONFIG) {
1408 hci_proto_connect_cfm(conn, status); 1408 hci_proto_connect_cfm(conn, status);
1409 hci_conn_put(conn); 1409 hci_conn_drop(conn);
1410 } 1410 }
1411 } 1411 }
1412 1412
@@ -1860,7 +1860,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
1860 } else { 1860 } else {
1861 conn->state = BT_CONNECT2; 1861 conn->state = BT_CONNECT2;
1862 hci_proto_connect_cfm(conn, 0); 1862 hci_proto_connect_cfm(conn, 0);
1863 hci_conn_put(conn); 1863 hci_conn_drop(conn);
1864 } 1864 }
1865 } else { 1865 } else {
1866 /* Connection rejected */ 1866 /* Connection rejected */
@@ -1967,14 +1967,14 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
1967 } else { 1967 } else {
1968 conn->state = BT_CONNECTED; 1968 conn->state = BT_CONNECTED;
1969 hci_proto_connect_cfm(conn, ev->status); 1969 hci_proto_connect_cfm(conn, ev->status);
1970 hci_conn_put(conn); 1970 hci_conn_drop(conn);
1971 } 1971 }
1972 } else { 1972 } else {
1973 hci_auth_cfm(conn, ev->status); 1973 hci_auth_cfm(conn, ev->status);
1974 1974
1975 hci_conn_hold(conn); 1975 hci_conn_hold(conn);
1976 conn->disc_timeout = HCI_DISCONN_TIMEOUT; 1976 conn->disc_timeout = HCI_DISCONN_TIMEOUT;
1977 hci_conn_put(conn); 1977 hci_conn_drop(conn);
1978 } 1978 }
1979 1979
1980 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { 1980 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) {
@@ -2058,7 +2058,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
2058 2058
2059 if (ev->status && conn->state == BT_CONNECTED) { 2059 if (ev->status && conn->state == BT_CONNECTED) {
2060 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); 2060 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
2061 hci_conn_put(conn); 2061 hci_conn_drop(conn);
2062 goto unlock; 2062 goto unlock;
2063 } 2063 }
2064 2064
@@ -2067,7 +2067,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
2067 conn->state = BT_CONNECTED; 2067 conn->state = BT_CONNECTED;
2068 2068
2069 hci_proto_connect_cfm(conn, ev->status); 2069 hci_proto_connect_cfm(conn, ev->status);
2070 hci_conn_put(conn); 2070 hci_conn_drop(conn);
2071 } else 2071 } else
2072 hci_encrypt_cfm(conn, ev->status, ev->encrypt); 2072 hci_encrypt_cfm(conn, ev->status, ev->encrypt);
2073 } 2073 }
@@ -2142,7 +2142,7 @@ static void hci_remote_features_evt(struct hci_dev *hdev,
2142 if (!hci_outgoing_auth_needed(hdev, conn)) { 2142 if (!hci_outgoing_auth_needed(hdev, conn)) {
2143 conn->state = BT_CONNECTED; 2143 conn->state = BT_CONNECTED;
2144 hci_proto_connect_cfm(conn, ev->status); 2144 hci_proto_connect_cfm(conn, ev->status);
2145 hci_conn_put(conn); 2145 hci_conn_drop(conn);
2146 } 2146 }
2147 2147
2148unlock: 2148unlock:
@@ -2682,7 +2682,7 @@ static void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
2682 if (conn->state == BT_CONNECTED) { 2682 if (conn->state == BT_CONNECTED) {
2683 hci_conn_hold(conn); 2683 hci_conn_hold(conn);
2684 conn->disc_timeout = HCI_PAIRING_TIMEOUT; 2684 conn->disc_timeout = HCI_PAIRING_TIMEOUT;
2685 hci_conn_put(conn); 2685 hci_conn_drop(conn);
2686 } 2686 }
2687 2687
2688 if (!test_bit(HCI_PAIRABLE, &hdev->dev_flags)) 2688 if (!test_bit(HCI_PAIRABLE, &hdev->dev_flags))
@@ -2785,7 +2785,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
2785 if (ev->key_type != HCI_LK_CHANGED_COMBINATION) 2785 if (ev->key_type != HCI_LK_CHANGED_COMBINATION)
2786 conn->key_type = ev->key_type; 2786 conn->key_type = ev->key_type;
2787 2787
2788 hci_conn_put(conn); 2788 hci_conn_drop(conn);
2789 } 2789 }
2790 2790
2791 if (test_bit(HCI_LINK_KEYS, &hdev->dev_flags)) 2791 if (test_bit(HCI_LINK_KEYS, &hdev->dev_flags))
@@ -2954,7 +2954,7 @@ static void hci_remote_ext_features_evt(struct hci_dev *hdev,
2954 if (!hci_outgoing_auth_needed(hdev, conn)) { 2954 if (!hci_outgoing_auth_needed(hdev, conn)) {
2955 conn->state = BT_CONNECTED; 2955 conn->state = BT_CONNECTED;
2956 hci_proto_connect_cfm(conn, ev->status); 2956 hci_proto_connect_cfm(conn, ev->status);
2957 hci_conn_put(conn); 2957 hci_conn_drop(conn);
2958 } 2958 }
2959 2959
2960unlock: 2960unlock:
@@ -3087,7 +3087,7 @@ static void hci_key_refresh_complete_evt(struct hci_dev *hdev,
3087 3087
3088 if (ev->status && conn->state == BT_CONNECTED) { 3088 if (ev->status && conn->state == BT_CONNECTED) {
3089 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); 3089 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
3090 hci_conn_put(conn); 3090 hci_conn_drop(conn);
3091 goto unlock; 3091 goto unlock;
3092 } 3092 }
3093 3093
@@ -3096,13 +3096,13 @@ static void hci_key_refresh_complete_evt(struct hci_dev *hdev,
3096 conn->state = BT_CONNECTED; 3096 conn->state = BT_CONNECTED;
3097 3097
3098 hci_proto_connect_cfm(conn, ev->status); 3098 hci_proto_connect_cfm(conn, ev->status);
3099 hci_conn_put(conn); 3099 hci_conn_drop(conn);
3100 } else { 3100 } else {
3101 hci_auth_cfm(conn, ev->status); 3101 hci_auth_cfm(conn, ev->status);
3102 3102
3103 hci_conn_hold(conn); 3103 hci_conn_hold(conn);
3104 conn->disc_timeout = HCI_DISCONN_TIMEOUT; 3104 conn->disc_timeout = HCI_DISCONN_TIMEOUT;
3105 hci_conn_put(conn); 3105 hci_conn_drop(conn);
3106 } 3106 }
3107 3107
3108unlock: 3108unlock:
@@ -3363,7 +3363,7 @@ static void hci_simple_pair_complete_evt(struct hci_dev *hdev,
3363 mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, 3363 mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type,
3364 ev->status); 3364 ev->status);
3365 3365
3366 hci_conn_put(conn); 3366 hci_conn_drop(conn);
3367 3367
3368unlock: 3368unlock:
3369 hci_dev_unlock(hdev); 3369 hci_dev_unlock(hdev);
@@ -3451,7 +3451,7 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev,
3451 3451
3452 hci_conn_hold(hcon); 3452 hci_conn_hold(hcon);
3453 hcon->disc_timeout = HCI_DISCONN_TIMEOUT; 3453 hcon->disc_timeout = HCI_DISCONN_TIMEOUT;
3454 hci_conn_put(hcon); 3454 hci_conn_drop(hcon);
3455 3455
3456 hci_conn_hold_device(hcon); 3456 hci_conn_hold_device(hcon);
3457 hci_conn_add_sysfs(hcon); 3457 hci_conn_add_sysfs(hcon);