Skip to content

Commit 19de082

Browse files
jhedbergholtmann
authored andcommitted
Bluetooth: Fix sending Device Removed when clearing all parameters
When calling Device Remove with BDADDR_ANY we should in a similar way emit Device Removed events as we do when removing a single device. Since we have to iterate the list and call device_removed() the dedicated hci_conn_params_clear_enabled() is not really useful anymore. This patch removes the helper function and does the event emission and list item removal in a single loop. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 9e1d7e1 commit 19de082

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type,
867867
void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type);
868868
void hci_conn_params_clear_all(struct hci_dev *hdev);
869869
void hci_conn_params_clear_disabled(struct hci_dev *hdev);
870-
void hci_conn_params_clear_enabled(struct hci_dev *hdev);
871870

872871
struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
873872
bdaddr_t *addr,

‎net/bluetooth/hci_core.c‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,24 +3621,6 @@ void hci_conn_params_clear_disabled(struct hci_dev *hdev)
36213621
BT_DBG("All LE disabled connection parameters were removed");
36223622
}
36233623

3624-
/* This function requires the caller holds hdev->lock */
3625-
void hci_conn_params_clear_enabled(struct hci_dev *hdev)
3626-
{
3627-
struct hci_conn_params *params, *tmp;
3628-
3629-
list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) {
3630-
if (params->auto_connect == HCI_AUTO_CONN_DISABLED)
3631-
continue;
3632-
list_del(&params->action);
3633-
list_del(&params->list);
3634-
kfree(params);
3635-
}
3636-
3637-
hci_update_background_scan(hdev);
3638-
3639-
BT_DBG("All enabled LE connection parameters were removed");
3640-
}
3641-
36423624
/* This function requires the caller holds hdev->lock */
36433625
void hci_conn_params_clear_all(struct hci_dev *hdev)
36443626
{

‎net/bluetooth/mgmt.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5284,14 +5284,27 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,
52845284

52855285
device_removed(sk, hdev, &cp->addr.bdaddr, cp->addr.type);
52865286
} else {
5287+
struct hci_conn_params *p, *tmp;
5288+
52875289
if (cp->addr.type) {
52885290
err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_DEVICE,
52895291
MGMT_STATUS_INVALID_PARAMS,
52905292
&cp->addr, sizeof(cp->addr));
52915293
goto unlock;
52925294
}
52935295

5294-
hci_conn_params_clear_enabled(hdev);
5296+
list_for_each_entry_safe(p, tmp, &hdev->le_conn_params, list) {
5297+
if (p->auto_connect == HCI_AUTO_CONN_DISABLED)
5298+
continue;
5299+
device_removed(sk, hdev, &p->addr, p->addr_type);
5300+
list_del(&p->action);
5301+
list_del(&p->list);
5302+
kfree(p);
5303+
}
5304+
5305+
BT_DBG("All LE connection parameters were removed");
5306+
5307+
hci_update_background_scan(hdev);
52955308
}
52965309

52975310
err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_DEVICE,

0 commit comments

Comments
 (0)