diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-04-06 14:28:37 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-04-11 15:34:15 -0400 |
commit | 76a68ba0ae097be72dfa8f918b3139130da769a4 (patch) | |
tree | 4a24ee83a895cfe49a23042989949e8b20d16deb | |
parent | 9f8f962c85461324d18dcb2b1b94a932494d2cc5 (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>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_conn.c | 6 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 36 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 6 | ||||
-rw-r--r-- | net/bluetooth/sco.c | 6 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 2 |
7 files changed, 32 insertions, 32 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d4e13bf5ae59..78ea9c7c202c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -612,7 +612,7 @@ static inline void hci_conn_hold(struct hci_conn *conn) | |||
612 | cancel_delayed_work(&conn->disc_work); | 612 | cancel_delayed_work(&conn->disc_work); |
613 | } | 613 | } |
614 | 614 | ||
615 | static inline void hci_conn_put(struct hci_conn *conn) | 615 | static inline void hci_conn_drop(struct hci_conn *conn) |
616 | { | 616 | { |
617 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); | 617 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); |
618 | 618 | ||
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b9f90169940b..30d7dfc23002 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -433,7 +433,7 @@ int hci_conn_del(struct hci_conn *conn) | |||
433 | struct hci_conn *acl = conn->link; | 433 | struct hci_conn *acl = conn->link; |
434 | if (acl) { | 434 | if (acl) { |
435 | acl->link = NULL; | 435 | acl->link = NULL; |
436 | hci_conn_put(acl); | 436 | hci_conn_drop(acl); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
@@ -565,7 +565,7 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, | |||
565 | if (!sco) { | 565 | if (!sco) { |
566 | sco = hci_conn_add(hdev, type, dst); | 566 | sco = hci_conn_add(hdev, type, dst); |
567 | if (!sco) { | 567 | if (!sco) { |
568 | hci_conn_put(acl); | 568 | hci_conn_drop(acl); |
569 | return ERR_PTR(-ENOMEM); | 569 | return ERR_PTR(-ENOMEM); |
570 | } | 570 | } |
571 | } | 571 | } |
@@ -980,7 +980,7 @@ void hci_chan_del(struct hci_chan *chan) | |||
980 | 980 | ||
981 | synchronize_rcu(); | 981 | synchronize_rcu(); |
982 | 982 | ||
983 | hci_conn_put(conn); | 983 | hci_conn_drop(conn); |
984 | 984 | ||
985 | skb_queue_purge(&chan->data_q); | 985 | skb_queue_purge(&chan->data_q); |
986 | kfree(chan); | 986 | kfree(chan); |
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 | ||
2148 | unlock: | 2148 | unlock: |
@@ -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 | ||
2960 | unlock: | 2960 | unlock: |
@@ -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 | ||
3108 | unlock: | 3108 | unlock: |
@@ -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 | ||
3368 | unlock: | 3368 | unlock: |
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); |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 7c7e9321f1ea..7cdb93c21b32 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -571,7 +571,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
571 | chan->conn = NULL; | 571 | chan->conn = NULL; |
572 | 572 | ||
573 | if (chan->chan_type != L2CAP_CHAN_CONN_FIX_A2MP) | 573 | if (chan->chan_type != L2CAP_CHAN_CONN_FIX_A2MP) |
574 | hci_conn_put(conn->hcon); | 574 | hci_conn_drop(conn->hcon); |
575 | 575 | ||
576 | if (mgr && mgr->bredr_chan == chan) | 576 | if (mgr && mgr->bredr_chan == chan) |
577 | mgr->bredr_chan = NULL; | 577 | mgr->bredr_chan = NULL; |
@@ -1697,7 +1697,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1697 | 1697 | ||
1698 | conn = l2cap_conn_add(hcon, 0); | 1698 | conn = l2cap_conn_add(hcon, 0); |
1699 | if (!conn) { | 1699 | if (!conn) { |
1700 | hci_conn_put(hcon); | 1700 | hci_conn_drop(hcon); |
1701 | err = -ENOMEM; | 1701 | err = -ENOMEM; |
1702 | goto done; | 1702 | goto done; |
1703 | } | 1703 | } |
@@ -1707,7 +1707,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1707 | 1707 | ||
1708 | if (!list_empty(&conn->chan_l)) { | 1708 | if (!list_empty(&conn->chan_l)) { |
1709 | err = -EBUSY; | 1709 | err = -EBUSY; |
1710 | hci_conn_put(hcon); | 1710 | hci_conn_drop(hcon); |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | if (err) | 1713 | if (err) |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 03e7e732215f..34ba1647e6e8 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2131,7 +2131,7 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) | |||
2131 | conn->security_cfm_cb = NULL; | 2131 | conn->security_cfm_cb = NULL; |
2132 | conn->disconn_cfm_cb = NULL; | 2132 | conn->disconn_cfm_cb = NULL; |
2133 | 2133 | ||
2134 | hci_conn_put(conn); | 2134 | hci_conn_drop(conn); |
2135 | 2135 | ||
2136 | mgmt_pending_remove(cmd); | 2136 | mgmt_pending_remove(cmd); |
2137 | } | 2137 | } |
@@ -2222,7 +2222,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
2222 | } | 2222 | } |
2223 | 2223 | ||
2224 | if (conn->connect_cfm_cb) { | 2224 | if (conn->connect_cfm_cb) { |
2225 | hci_conn_put(conn); | 2225 | hci_conn_drop(conn); |
2226 | err = cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, | 2226 | err = cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, |
2227 | MGMT_STATUS_BUSY, &rp, sizeof(rp)); | 2227 | MGMT_STATUS_BUSY, &rp, sizeof(rp)); |
2228 | goto unlock; | 2228 | goto unlock; |
@@ -2231,7 +2231,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
2231 | cmd = mgmt_pending_add(sk, MGMT_OP_PAIR_DEVICE, hdev, data, len); | 2231 | cmd = mgmt_pending_add(sk, MGMT_OP_PAIR_DEVICE, hdev, data, len); |
2232 | if (!cmd) { | 2232 | if (!cmd) { |
2233 | err = -ENOMEM; | 2233 | err = -ENOMEM; |
2234 | hci_conn_put(conn); | 2234 | hci_conn_drop(conn); |
2235 | goto unlock; | 2235 | goto unlock; |
2236 | } | 2236 | } |
2237 | 2237 | ||
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index d919d1161ab4..9909eec6afe3 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -185,7 +185,7 @@ static int sco_connect(struct sock *sk) | |||
185 | 185 | ||
186 | conn = sco_conn_add(hcon); | 186 | conn = sco_conn_add(hcon); |
187 | if (!conn) { | 187 | if (!conn) { |
188 | hci_conn_put(hcon); | 188 | hci_conn_drop(hcon); |
189 | err = -ENOMEM; | 189 | err = -ENOMEM; |
190 | goto done; | 190 | goto done; |
191 | } | 191 | } |
@@ -353,7 +353,7 @@ static void __sco_sock_close(struct sock *sk) | |||
353 | if (sco_pi(sk)->conn->hcon) { | 353 | if (sco_pi(sk)->conn->hcon) { |
354 | sk->sk_state = BT_DISCONN; | 354 | sk->sk_state = BT_DISCONN; |
355 | sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT); | 355 | sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT); |
356 | hci_conn_put(sco_pi(sk)->conn->hcon); | 356 | hci_conn_drop(sco_pi(sk)->conn->hcon); |
357 | sco_pi(sk)->conn->hcon = NULL; | 357 | sco_pi(sk)->conn->hcon = NULL; |
358 | } else | 358 | } else |
359 | sco_chan_del(sk, ECONNRESET); | 359 | sco_chan_del(sk, ECONNRESET); |
@@ -882,7 +882,7 @@ static void sco_chan_del(struct sock *sk, int err) | |||
882 | sco_conn_unlock(conn); | 882 | sco_conn_unlock(conn); |
883 | 883 | ||
884 | if (conn->hcon) | 884 | if (conn->hcon) |
885 | hci_conn_put(conn->hcon); | 885 | hci_conn_drop(conn->hcon); |
886 | } | 886 | } |
887 | 887 | ||
888 | sk->sk_state = BT_CLOSED; | 888 | sk->sk_state = BT_CLOSED; |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 5abefb12891d..b2296d3857a0 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -522,7 +522,7 @@ void smp_chan_destroy(struct l2cap_conn *conn) | |||
522 | kfree(smp); | 522 | kfree(smp); |
523 | conn->smp_chan = NULL; | 523 | conn->smp_chan = NULL; |
524 | conn->hcon->smp_conn = NULL; | 524 | conn->hcon->smp_conn = NULL; |
525 | hci_conn_put(conn->hcon); | 525 | hci_conn_drop(conn->hcon); |
526 | } | 526 | } |
527 | 527 | ||
528 | int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) | 528 | int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) |