aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h4
-rw-r--r--net/bluetooth/hci_conn.c17
-rw-r--r--net/bluetooth/hci_event.c4
-rw-r--r--net/bluetooth/hidp/core.c20
4 files changed, 4 insertions, 41 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 78ea9c7c202c..5590cc4412c6 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -345,7 +345,6 @@ struct hci_conn {
345 struct timer_list auto_accept_timer; 345 struct timer_list auto_accept_timer;
346 346
347 struct device dev; 347 struct device dev;
348 atomic_t devref;
349 348
350 struct hci_dev *hdev; 349 struct hci_dev *hdev;
351 void *l2cap_data; 350 void *l2cap_data;
@@ -601,9 +600,6 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
601 600
602void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); 601void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
603 602
604void hci_conn_hold_device(struct hci_conn *conn);
605void hci_conn_put_device(struct hci_conn *conn);
606
607static inline void hci_conn_hold(struct hci_conn *conn) 603static inline void hci_conn_hold(struct hci_conn *conn)
608{ 604{
609 BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); 605 BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt));
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index b1a02ce39a20..6b5b8e77cf0b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -410,8 +410,6 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
410 if (hdev->notify) 410 if (hdev->notify)
411 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD); 411 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
412 412
413 atomic_set(&conn->devref, 0);
414
415 hci_conn_init_sysfs(conn); 413 hci_conn_init_sysfs(conn);
416 414
417 return conn; 415 return conn;
@@ -460,7 +458,7 @@ int hci_conn_del(struct hci_conn *conn)
460 458
461 skb_queue_purge(&conn->data_q); 459 skb_queue_purge(&conn->data_q);
462 460
463 hci_conn_put_device(conn); 461 hci_conn_del_sysfs(conn);
464 462
465 hci_dev_put(hdev); 463 hci_dev_put(hdev);
466 464
@@ -847,19 +845,6 @@ void hci_conn_check_pending(struct hci_dev *hdev)
847 hci_dev_unlock(hdev); 845 hci_dev_unlock(hdev);
848} 846}
849 847
850void hci_conn_hold_device(struct hci_conn *conn)
851{
852 atomic_inc(&conn->devref);
853}
854EXPORT_SYMBOL(hci_conn_hold_device);
855
856void hci_conn_put_device(struct hci_conn *conn)
857{
858 if (atomic_dec_and_test(&conn->devref))
859 hci_conn_del_sysfs(conn);
860}
861EXPORT_SYMBOL(hci_conn_put_device);
862
863int hci_get_conn_list(void __user *arg) 848int hci_get_conn_list(void __user *arg)
864{ 849{
865 struct hci_conn *c; 850 struct hci_conn *c;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index f6ea3c734269..688c1a9949cc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1706,7 +1706,6 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
1706 } else 1706 } else
1707 conn->state = BT_CONNECTED; 1707 conn->state = BT_CONNECTED;
1708 1708
1709 hci_conn_hold_device(conn);
1710 hci_conn_add_sysfs(conn); 1709 hci_conn_add_sysfs(conn);
1711 1710
1712 if (test_bit(HCI_AUTH, &hdev->flags)) 1711 if (test_bit(HCI_AUTH, &hdev->flags))
@@ -2987,7 +2986,6 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
2987 conn->handle = __le16_to_cpu(ev->handle); 2986 conn->handle = __le16_to_cpu(ev->handle);
2988 conn->state = BT_CONNECTED; 2987 conn->state = BT_CONNECTED;
2989 2988
2990 hci_conn_hold_device(conn);
2991 hci_conn_add_sysfs(conn); 2989 hci_conn_add_sysfs(conn);
2992 break; 2990 break;
2993 2991
@@ -3452,7 +3450,6 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev,
3452 hcon->disc_timeout = HCI_DISCONN_TIMEOUT; 3450 hcon->disc_timeout = HCI_DISCONN_TIMEOUT;
3453 hci_conn_drop(hcon); 3451 hci_conn_drop(hcon);
3454 3452
3455 hci_conn_hold_device(hcon);
3456 hci_conn_add_sysfs(hcon); 3453 hci_conn_add_sysfs(hcon);
3457 3454
3458 amp_physical_cfm(bredr_hcon, hcon); 3455 amp_physical_cfm(bredr_hcon, hcon);
@@ -3586,7 +3583,6 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
3586 conn->handle = __le16_to_cpu(ev->handle); 3583 conn->handle = __le16_to_cpu(ev->handle);
3587 conn->state = BT_CONNECTED; 3584 conn->state = BT_CONNECTED;
3588 3585
3589 hci_conn_hold_device(conn);
3590 hci_conn_add_sysfs(conn); 3586 hci_conn_add_sysfs(conn);
3591 3587
3592 hci_proto_connect_cfm(conn, ev->status); 3588 hci_proto_connect_cfm(conn, ev->status);
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 4ab82cb3eac3..9734136d6431 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -73,18 +73,6 @@ static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr)
73 return NULL; 73 return NULL;
74} 74}
75 75
76static void __hidp_link_session(struct hidp_session *session)
77{
78 list_add(&session->list, &hidp_session_list);
79}
80
81static void __hidp_unlink_session(struct hidp_session *session)
82{
83 hci_conn_put_device(session->conn);
84
85 list_del(&session->list);
86}
87
88static void __hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci) 76static void __hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci)
89{ 77{
90 memset(ci, 0, sizeof(*ci)); 78 memset(ci, 0, sizeof(*ci));
@@ -760,7 +748,7 @@ static int hidp_session(void *arg)
760 748
761 fput(session->ctrl_sock->file); 749 fput(session->ctrl_sock->file);
762 750
763 __hidp_unlink_session(session); 751 list_del(&session->list);
764 752
765 up_write(&hidp_session_sem); 753 up_write(&hidp_session_sem);
766 754
@@ -783,8 +771,6 @@ static struct hci_conn *hidp_get_connection(struct hidp_session *session)
783 771
784 hci_dev_lock(hdev); 772 hci_dev_lock(hdev);
785 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 773 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
786 if (conn)
787 hci_conn_hold_device(conn);
788 hci_dev_unlock(hdev); 774 hci_dev_unlock(hdev);
789 775
790 hci_dev_put(hdev); 776 hci_dev_put(hdev);
@@ -1026,7 +1012,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
1026 session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID); 1012 session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID);
1027 session->idle_to = req->idle_to; 1013 session->idle_to = req->idle_to;
1028 1014
1029 __hidp_link_session(session); 1015 list_add(&session->list, &hidp_session_list);
1030 1016
1031 if (req->rd_size > 0) { 1017 if (req->rd_size > 0) {
1032 err = hidp_setup_hid(session, req); 1018 err = hidp_setup_hid(session, req);
@@ -1106,7 +1092,7 @@ unlink:
1106 session->rd_data = NULL; 1092 session->rd_data = NULL;
1107 1093
1108purge: 1094purge:
1109 __hidp_unlink_session(session); 1095 list_del(&session->list);
1110 1096
1111 skb_queue_purge(&session->ctrl_transmit); 1097 skb_queue_purge(&session->ctrl_transmit);
1112 skb_queue_purge(&session->intr_transmit); 1098 skb_queue_purge(&session->intr_transmit);