Commit 851efca8 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Track number of added devices with HCI_AUTO_CONN_REPORT

To be able to make the right choice of whether to start passive scanning
or to send out a mgmt_device_found event we need to know if there are
any devices in the le_conn_params list with the auto_connect value set
to HCI_AUTO_CONN_REPORT. This patch adds a counter for this kind of
devices.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 82a30cfc
...@@ -312,6 +312,7 @@ struct hci_dev { ...@@ -312,6 +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 hci_dev_stats stat; struct hci_dev_stats stat;
......
...@@ -3545,20 +3545,28 @@ int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type, ...@@ -3545,20 +3545,28 @@ int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type,
if (!params) if (!params)
return -EIO; return -EIO;
params->auto_connect = auto_connect; if (params->auto_connect == HCI_AUTO_CONN_REPORT &&
auto_connect != HCI_AUTO_CONN_REPORT)
hdev->pend_le_reports--;
switch (auto_connect) { switch (auto_connect) {
case HCI_AUTO_CONN_DISABLED: case HCI_AUTO_CONN_DISABLED:
case HCI_AUTO_CONN_REPORT:
case HCI_AUTO_CONN_LINK_LOSS: case HCI_AUTO_CONN_LINK_LOSS:
hci_pend_le_conn_del(hdev, addr, addr_type); hci_pend_le_conn_del(hdev, addr, addr_type);
break; break;
case HCI_AUTO_CONN_REPORT:
if (params->auto_connect != HCI_AUTO_CONN_REPORT)
hdev->pend_le_reports++;
hci_pend_le_conn_del(hdev, addr, addr_type);
break;
case HCI_AUTO_CONN_ALWAYS: case HCI_AUTO_CONN_ALWAYS:
if (!is_connected(hdev, addr, addr_type)) if (!is_connected(hdev, addr, addr_type))
hci_pend_le_conn_add(hdev, addr, addr_type); hci_pend_le_conn_add(hdev, addr, addr_type);
break; break;
} }
params->auto_connect = auto_connect;
BT_DBG("addr %pMR (type %u) auto_connect %u", addr, addr_type, BT_DBG("addr %pMR (type %u) auto_connect %u", addr, addr_type,
auto_connect); auto_connect);
...@@ -3574,6 +3582,9 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type) ...@@ -3574,6 +3582,9 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
if (!params) if (!params)
return; return;
if (params->auto_connect == HCI_AUTO_CONN_REPORT)
hdev->pend_le_reports--;
hci_pend_le_conn_del(hdev, addr, addr_type); hci_pend_le_conn_del(hdev, addr, addr_type);
list_del(&params->list); list_del(&params->list);
...@@ -3605,6 +3616,8 @@ void hci_conn_params_clear_enabled(struct hci_dev *hdev) ...@@ -3605,6 +3616,8 @@ void hci_conn_params_clear_enabled(struct hci_dev *hdev)
list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) { list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) {
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)
hdev->pend_le_reports--;
list_del(&params->list); list_del(&params->list);
kfree(params); kfree(params);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment