Bluetooth: Convert pend_le_reports into a list
To simplify manipulation and lookup of hci_conn_params entries of the type HCI_AUTO_CONN_REPORT it makes sense to store them in their own list. The new action list_head in hci_conn_params is used for this purpose. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
93450c7544
commit
66f8455aea
4 changed files with 15 additions and 10 deletions
|
@ -312,7 +312,7 @@ struct hci_dev {
|
||||||
struct list_head le_white_list;
|
struct list_head le_white_list;
|
||||||
struct list_head le_conn_params;
|
struct list_head le_conn_params;
|
||||||
struct list_head pend_le_conns;
|
struct list_head pend_le_conns;
|
||||||
unsigned int pend_le_reports;
|
struct list_head pend_le_reports;
|
||||||
|
|
||||||
struct hci_dev_stats stat;
|
struct hci_dev_stats stat;
|
||||||
|
|
||||||
|
|
|
@ -3529,7 +3529,7 @@ int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type,
|
||||||
|
|
||||||
if (params->auto_connect == HCI_AUTO_CONN_REPORT &&
|
if (params->auto_connect == HCI_AUTO_CONN_REPORT &&
|
||||||
auto_connect != HCI_AUTO_CONN_REPORT)
|
auto_connect != HCI_AUTO_CONN_REPORT)
|
||||||
hdev->pend_le_reports--;
|
list_del_init(¶ms->action);
|
||||||
|
|
||||||
switch (auto_connect) {
|
switch (auto_connect) {
|
||||||
case HCI_AUTO_CONN_DISABLED:
|
case HCI_AUTO_CONN_DISABLED:
|
||||||
|
@ -3537,8 +3537,11 @@ int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type,
|
||||||
hci_pend_le_conn_del(hdev, params);
|
hci_pend_le_conn_del(hdev, params);
|
||||||
break;
|
break;
|
||||||
case HCI_AUTO_CONN_REPORT:
|
case HCI_AUTO_CONN_REPORT:
|
||||||
if (params->auto_connect != HCI_AUTO_CONN_REPORT)
|
if (params->auto_connect != HCI_AUTO_CONN_REPORT) {
|
||||||
hdev->pend_le_reports++;
|
list_del_init(¶ms->action);
|
||||||
|
list_add(¶ms->action,
|
||||||
|
&hdev->pend_le_reports);
|
||||||
|
}
|
||||||
hci_pend_le_conn_del(hdev, params);
|
hci_pend_le_conn_del(hdev, params);
|
||||||
break;
|
break;
|
||||||
case HCI_AUTO_CONN_ALWAYS:
|
case HCI_AUTO_CONN_ALWAYS:
|
||||||
|
@ -3565,7 +3568,7 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
|
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
|
||||||
hdev->pend_le_reports--;
|
list_del_init(¶ms->action);
|
||||||
|
|
||||||
hci_pend_le_conn_del(hdev, params);
|
hci_pend_le_conn_del(hdev, params);
|
||||||
|
|
||||||
|
@ -3599,7 +3602,7 @@ void hci_conn_params_clear_enabled(struct hci_dev *hdev)
|
||||||
if (params->auto_connect == HCI_AUTO_CONN_DISABLED)
|
if (params->auto_connect == HCI_AUTO_CONN_DISABLED)
|
||||||
continue;
|
continue;
|
||||||
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
|
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
|
||||||
hdev->pend_le_reports--;
|
list_del_init(¶ms->action);
|
||||||
list_del(¶ms->list);
|
list_del(¶ms->list);
|
||||||
kfree(params);
|
kfree(params);
|
||||||
}
|
}
|
||||||
|
@ -3859,6 +3862,7 @@ struct hci_dev *hci_alloc_dev(void)
|
||||||
INIT_LIST_HEAD(&hdev->le_white_list);
|
INIT_LIST_HEAD(&hdev->le_white_list);
|
||||||
INIT_LIST_HEAD(&hdev->le_conn_params);
|
INIT_LIST_HEAD(&hdev->le_conn_params);
|
||||||
INIT_LIST_HEAD(&hdev->pend_le_conns);
|
INIT_LIST_HEAD(&hdev->pend_le_conns);
|
||||||
|
INIT_LIST_HEAD(&hdev->pend_le_reports);
|
||||||
INIT_LIST_HEAD(&hdev->conn_hash.list);
|
INIT_LIST_HEAD(&hdev->conn_hash.list);
|
||||||
|
|
||||||
INIT_WORK(&hdev->rx_work, hci_rx_work);
|
INIT_WORK(&hdev->rx_work, hci_rx_work);
|
||||||
|
@ -5362,7 +5366,8 @@ void hci_update_background_scan(struct hci_dev *hdev)
|
||||||
|
|
||||||
hci_req_init(&req, hdev);
|
hci_req_init(&req, hdev);
|
||||||
|
|
||||||
if (list_empty(&hdev->pend_le_conns) && !hdev->pend_le_reports) {
|
if (list_empty(&hdev->pend_le_conns) &&
|
||||||
|
list_empty(&hdev->pend_le_reports)) {
|
||||||
/* If there is no pending LE connections or devices
|
/* If there is no pending LE connections or devices
|
||||||
* to be scanned for, we should stop the background
|
* to be scanned for, we should stop the background
|
||||||
* scanning.
|
* scanning.
|
||||||
|
|
|
@ -4240,7 +4240,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hdev->pend_le_reports)
|
if (list_empty(&hdev->pend_le_reports))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (type == LE_ADV_DIRECT_IND)
|
if (type == LE_ADV_DIRECT_IND)
|
||||||
|
|
|
@ -5226,7 +5226,7 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
|
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
|
||||||
hdev->pend_le_reports--;
|
list_del_init(¶ms->action);
|
||||||
|
|
||||||
hci_pend_le_conn_del(hdev, params);
|
hci_pend_le_conn_del(hdev, params);
|
||||||
list_del(¶ms->list);
|
list_del(¶ms->list);
|
||||||
|
@ -6540,7 +6540,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
|
||||||
if (!hci_discovery_active(hdev)) {
|
if (!hci_discovery_active(hdev)) {
|
||||||
if (link_type == ACL_LINK)
|
if (link_type == ACL_LINK)
|
||||||
return;
|
return;
|
||||||
if (link_type == LE_LINK && !hdev->pend_le_reports)
|
if (link_type == LE_LINK && list_empty(&hdev->pend_le_reports))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue