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>
This commit is contained in:
committed by
Marcel Holtmann
parent
5477610fc1
commit
51bb8457dd
@@ -1695,9 +1695,10 @@ static void l2cap_conn_free(struct kref *ref)
|
||||
kfree(conn);
|
||||
}
|
||||
|
||||
void l2cap_conn_get(struct l2cap_conn *conn)
|
||||
struct l2cap_conn *l2cap_conn_get(struct l2cap_conn *conn)
|
||||
{
|
||||
kref_get(&conn->ref);
|
||||
return conn;
|
||||
}
|
||||
EXPORT_SYMBOL(l2cap_conn_get);
|
||||
|
||||
@@ -6908,8 +6909,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon)
|
||||
|
||||
kref_init(&conn->ref);
|
||||
hcon->l2cap_data = conn;
|
||||
conn->hcon = hcon;
|
||||
hci_conn_get(conn->hcon);
|
||||
conn->hcon = hci_conn_get(hcon);
|
||||
conn->hchan = hchan;
|
||||
|
||||
BT_DBG("hcon %p conn %p hchan %p", hcon, conn, hchan);
|
||||
|
||||
Reference in New Issue
Block a user