diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-08-15 22:06:59 +0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-09-08 21:07:53 +0400 |
commit | f6c63249698aaa87399e795adcf3b70171384dc2 (patch) | |
tree | 9c722bd8313116f1a472c70427c297f17cb52289 /net/bluetooth | |
parent | f8aaf9b65a77267f749c1af641e46c3457d50701 (diff) | |
download | linux-f6c63249698aaa87399e795adcf3b70171384dc2.tar.xz |
Bluetooth: Refactor connection parameter freeing into its own function
The necessary steps for freeing connection paramaters have grown quite a
bit so we can simplify the code by factoring it out into its own
function.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ed60d37ea646..0d3782ad9a5b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3726,15 +3726,8 @@ int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type, return 0; } -/* This function requires the caller holds hdev->lock */ -void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type) +static void hci_conn_params_free(struct hci_conn_params *params) { - struct hci_conn_params *params; - - params = hci_conn_params_lookup(hdev, addr, addr_type); - if (!params) - return; - if (params->conn) { hci_conn_drop(params->conn); hci_conn_put(params->conn); @@ -3743,6 +3736,18 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type) list_del(¶ms->action); list_del(¶ms->list); kfree(params); +} + +/* This function requires the caller holds hdev->lock */ +void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type) +{ + struct hci_conn_params *params; + + params = hci_conn_params_lookup(hdev, addr, addr_type); + if (!params) + return; + + hci_conn_params_free(params); hci_update_background_scan(hdev); @@ -3769,15 +3774,8 @@ void hci_conn_params_clear_all(struct hci_dev *hdev) { struct hci_conn_params *params, *tmp; - list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) { - if (params->conn) { - hci_conn_drop(params->conn); - hci_conn_put(params->conn); - } - list_del(¶ms->action); - list_del(¶ms->list); - kfree(params); - } + list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) + hci_conn_params_free(params); hci_update_background_scan(hdev); |