aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2014-02-26 18:21:46 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-02-26 22:41:34 -0500
commit77a77a30ae893a63467c51e45de18d0bdfa612e4 (patch)
tree220f47fde3fcaa2c23958ec371820994edda646e /net/bluetooth/hci_core.c
parent6f77d8c757523f675679d845ff0e15d3276a168a (diff)
Bluetooth: Introduce hdev->pend_le_conn list
This patch introduces the hdev->pend_le_conn list which holds the device addresses the kernel should autonomously connect. It also introduces some helper functions to manipulate the list. The list and helper functions will be used by the next patch which implements the LE auto connection infrastructure. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9a078cf81d3f..142ecd846ccd 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3259,6 +3259,72 @@ void hci_conn_params_clear(struct hci_dev *hdev)
3259 BT_DBG("All LE connection parameters were removed"); 3259 BT_DBG("All LE connection parameters were removed");
3260} 3260}
3261 3261
3262/* This function requires the caller holds hdev->lock */
3263struct bdaddr_list *hci_pend_le_conn_lookup(struct hci_dev *hdev,
3264 bdaddr_t *addr, u8 addr_type)
3265{
3266 struct bdaddr_list *entry;
3267
3268 list_for_each_entry(entry, &hdev->pend_le_conns, list) {
3269 if (bacmp(&entry->bdaddr, addr) == 0 &&
3270 entry->bdaddr_type == addr_type)
3271 return entry;
3272 }
3273
3274 return NULL;
3275}
3276
3277/* This function requires the caller holds hdev->lock */
3278void hci_pend_le_conn_add(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
3279{
3280 struct bdaddr_list *entry;
3281
3282 entry = hci_pend_le_conn_lookup(hdev, addr, addr_type);
3283 if (entry)
3284 return;
3285
3286 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
3287 if (!entry) {
3288 BT_ERR("Out of memory");
3289 return;
3290 }
3291
3292 bacpy(&entry->bdaddr, addr);
3293 entry->bdaddr_type = addr_type;
3294
3295 list_add(&entry->list, &hdev->pend_le_conns);
3296
3297 BT_DBG("addr %pMR (type %u)", addr, addr_type);
3298}
3299
3300/* This function requires the caller holds hdev->lock */
3301void hci_pend_le_conn_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
3302{
3303 struct bdaddr_list *entry;
3304
3305 entry = hci_pend_le_conn_lookup(hdev, addr, addr_type);
3306 if (!entry)
3307 return;
3308
3309 list_del(&entry->list);
3310 kfree(entry);
3311
3312 BT_DBG("addr %pMR (type %u)", addr, addr_type);
3313}
3314
3315/* This function requires the caller holds hdev->lock */
3316void hci_pend_le_conns_clear(struct hci_dev *hdev)
3317{
3318 struct bdaddr_list *entry, *tmp;
3319
3320 list_for_each_entry_safe(entry, tmp, &hdev->pend_le_conns, list) {
3321 list_del(&entry->list);
3322 kfree(entry);
3323 }
3324
3325 BT_DBG("All LE pending connections cleared");
3326}
3327
3262static void inquiry_complete(struct hci_dev *hdev, u8 status) 3328static void inquiry_complete(struct hci_dev *hdev, u8 status)
3263{ 3329{
3264 if (status) { 3330 if (status) {
@@ -3441,6 +3507,7 @@ struct hci_dev *hci_alloc_dev(void)
3441 INIT_LIST_HEAD(&hdev->identity_resolving_keys); 3507 INIT_LIST_HEAD(&hdev->identity_resolving_keys);
3442 INIT_LIST_HEAD(&hdev->remote_oob_data); 3508 INIT_LIST_HEAD(&hdev->remote_oob_data);
3443 INIT_LIST_HEAD(&hdev->le_conn_params); 3509 INIT_LIST_HEAD(&hdev->le_conn_params);
3510 INIT_LIST_HEAD(&hdev->pend_le_conns);
3444 INIT_LIST_HEAD(&hdev->conn_hash.list); 3511 INIT_LIST_HEAD(&hdev->conn_hash.list);
3445 3512
3446 INIT_WORK(&hdev->rx_work, hci_rx_work); 3513 INIT_WORK(&hdev->rx_work, hci_rx_work);
@@ -3642,6 +3709,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
3642 hci_smp_irks_clear(hdev); 3709 hci_smp_irks_clear(hdev);
3643 hci_remote_oob_data_clear(hdev); 3710 hci_remote_oob_data_clear(hdev);
3644 hci_conn_params_clear(hdev); 3711 hci_conn_params_clear(hdev);
3712 hci_pend_le_conns_clear(hdev);
3645 hci_dev_unlock(hdev); 3713 hci_dev_unlock(hdev);
3646 3714
3647 hci_dev_put(hdev); 3715 hci_dev_put(hdev);