aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-06-24 06:15:48 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-03 11:42:45 -0400
commit567fa2aa3dfad9848c25a226927a4ca5f94229ac (patch)
treee16506334c4b7e2f89012c873ffe3567549934a1
parent37f468cd171c7d76d560b6bd5c09dc506ab9dbec (diff)
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>
-rw-r--r--include/net/bluetooth/hci_core.h5
-rw-r--r--net/bluetooth/hci_core.c11
2 files changed, 9 insertions, 7 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index cd73a82cc713..7f81791a865d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -859,8 +859,9 @@ void hci_uuids_clear(struct hci_dev *hdev);
859 859
860void hci_link_keys_clear(struct hci_dev *hdev); 860void hci_link_keys_clear(struct hci_dev *hdev);
861struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); 861struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
862int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, 862struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
863 bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); 863 int new_key, bdaddr_t *bdaddr, u8 *val,
864 u8 type, u8 pin_len);
864struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, __le64 rand, 865struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, __le64 rand,
865 bool master); 866 bool master);
866struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, 867struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
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,
3001 return NULL; 3001 return NULL;
3002} 3002}
3003 3003
3004int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, 3004struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
3005 bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) 3005 int new_key, bdaddr_t *bdaddr, u8 *val,
3006 u8 type, u8 pin_len)
3006{ 3007{
3007 struct link_key *key, *old_key; 3008 struct link_key *key, *old_key;
3008 u8 old_key_type; 3009 u8 old_key_type;
@@ -3016,7 +3017,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
3016 old_key_type = conn ? conn->key_type : 0xff; 3017 old_key_type = conn ? conn->key_type : 0xff;
3017 key = kzalloc(sizeof(*key), GFP_KERNEL); 3018 key = kzalloc(sizeof(*key), GFP_KERNEL);
3018 if (!key) 3019 if (!key)
3019 return -ENOMEM; 3020 return NULL;
3020 list_add(&key->list, &hdev->link_keys); 3021 list_add(&key->list, &hdev->link_keys);
3021 } 3022 }
3022 3023
@@ -3042,7 +3043,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
3042 key->type = type; 3043 key->type = type;
3043 3044
3044 if (!new_key) 3045 if (!new_key)
3045 return 0; 3046 return key;
3046 3047
3047 persistent = hci_persistent_key(hdev, conn, type, old_key_type); 3048 persistent = hci_persistent_key(hdev, conn, type, old_key_type);
3048 3049
@@ -3051,7 +3052,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
3051 if (conn) 3052 if (conn)
3052 conn->flush_key = !persistent; 3053 conn->flush_key = !persistent;
3053 3054
3054 return 0; 3055 return key;
3055} 3056}
3056 3057
3057struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, 3058struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,