summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-06-24 13:15:48 +0300
committerMarcel Holtmann <marcel@holtmann.org>2014-07-03 17:42:45 +0200
commit567fa2aa3dfad9848c25a226927a4ca5f94229ac (patch)
treee16506334c4b7e2f89012c873ffe3567549934a1 /net
parent37f468cd171c7d76d560b6bd5c09dc506ab9dbec (diff)
downloadlwn-567fa2aa3dfad9848c25a226927a4ca5f94229ac.tar.gz
lwn-567fa2aa3dfad9848c25a226927a4ca5f94229ac.zip
Bluetooth: Update hci_add_link_key() to return pointer to key
By returning the added (or updated) key we pave the way for further refactoring (in subsequent patches) that allows moving the mgmt event sending out from this function (and thereby removal of the awkward new_key parameter). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_core.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index bbfc5455acec..ee42788aed2c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3001,8 +3001,9 @@ struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
return NULL;
}
-int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
- bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
+struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+ int new_key, bdaddr_t *bdaddr, u8 *val,
+ u8 type, u8 pin_len)
{
struct link_key *key, *old_key;
u8 old_key_type;
@@ -3016,7 +3017,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
old_key_type = conn ? conn->key_type : 0xff;
key = kzalloc(sizeof(*key), GFP_KERNEL);
if (!key)
- return -ENOMEM;
+ return NULL;
list_add(&key->list, &hdev->link_keys);
}
@@ -3042,7 +3043,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
key->type = type;
if (!new_key)
- return 0;
+ return key;
persistent = hci_persistent_key(hdev, conn, type, old_key_type);
@@ -3051,7 +3052,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
if (conn)
conn->flush_key = !persistent;
- return 0;
+ return key;
}
struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,