aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hidp/core.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-08-15 14:06:57 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-09-08 13:07:52 -0400
commit51bb8457ddfa74ede52bf8c02054dea831d59fff (patch)
tree668dd96aa65093142ca79ce55cdca68067fcc129 /net/bluetooth/hidp/core.c
parent5477610fc187d4aae0f699d21dfb0e3f440f7de7 (diff)
Bluetooth: Improve *_get() functions to return the object type
It's natural to have *_get() functions that increment the reference count of an object to return the object type itself. This way it's simple to make a copy of the object pointer and increase the reference count in a single step. This patch updates two such get() functions, namely hci_conn_get() and l2cap_conn_get(), and updates the users to take advantage of the new API. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hidp/core.c')
-rw-r--r--net/bluetooth/hidp/core.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 6c7ecf116e74..1b7d605706aa 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -915,7 +915,7 @@ static int hidp_session_new(struct hidp_session **out, const bdaddr_t *bdaddr,
915 915
916 /* connection management */ 916 /* connection management */
917 bacpy(&session->bdaddr, bdaddr); 917 bacpy(&session->bdaddr, bdaddr);
918 session->conn = conn; 918 session->conn = l2cap_conn_get(conn);
919 session->user.probe = hidp_session_probe; 919 session->user.probe = hidp_session_probe;
920 session->user.remove = hidp_session_remove; 920 session->user.remove = hidp_session_remove;
921 session->ctrl_sock = ctrl_sock; 921 session->ctrl_sock = ctrl_sock;
@@ -941,13 +941,13 @@ static int hidp_session_new(struct hidp_session **out, const bdaddr_t *bdaddr,
941 if (ret) 941 if (ret)
942 goto err_free; 942 goto err_free;
943 943
944 l2cap_conn_get(session->conn);
945 get_file(session->intr_sock->file); 944 get_file(session->intr_sock->file);
946 get_file(session->ctrl_sock->file); 945 get_file(session->ctrl_sock->file);
947 *out = session; 946 *out = session;
948 return 0; 947 return 0;
949 948
950err_free: 949err_free:
950 l2cap_conn_put(session->conn);
951 kfree(session); 951 kfree(session);
952 return ret; 952 return ret;
953} 953}
@@ -1327,10 +1327,8 @@ int hidp_connection_add(struct hidp_connadd_req *req,
1327 1327
1328 conn = NULL; 1328 conn = NULL;
1329 l2cap_chan_lock(chan); 1329 l2cap_chan_lock(chan);
1330 if (chan->conn) { 1330 if (chan->conn)
1331 l2cap_conn_get(chan->conn); 1331 conn = l2cap_conn_get(chan->conn);
1332 conn = chan->conn;
1333 }
1334 l2cap_chan_unlock(chan); 1332 l2cap_chan_unlock(chan);
1335 1333
1336 if (!conn) 1334 if (!conn)