aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-06-20 15:39:29 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-12-18 14:07:55 -0500
commitdb323f2fff0ded058f033df6235e8c2be4146bfd (patch)
tree4e267f325506f2cff3b496dc1c52cde57c4a74fd
parent19c40e3bcaf2d969f5d4ee85bbe1330b54d36d9c (diff)
Bluetooth: Use delayed work for advertisiment cache timeout
As HCI rx path is now done in process context it makes sense to do all the timer in process context as well. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--net/bluetooth/hci_core.c10
-rw-r--r--net/bluetooth/hci_event.c6
3 files changed, 10 insertions, 8 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d91590850429..14b200b08d84 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -226,7 +226,7 @@ struct hci_dev {
226 struct list_head remote_oob_data; 226 struct list_head remote_oob_data;
227 227
228 struct list_head adv_entries; 228 struct list_head adv_entries;
229 struct timer_list adv_timer; 229 struct delayed_work adv_work;
230 230
231 struct hci_dev_stats stat; 231 struct hci_dev_stats stat;
232 232
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ec1019178f80..6f5bb3cbf6f6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1340,9 +1340,10 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr)
1340 return mgmt_device_unblocked(hdev, bdaddr); 1340 return mgmt_device_unblocked(hdev, bdaddr);
1341} 1341}
1342 1342
1343static void hci_clear_adv_cache(unsigned long arg) 1343static void hci_clear_adv_cache(struct work_struct *work)
1344{ 1344{
1345 struct hci_dev *hdev = (void *) arg; 1345 struct hci_dev *hdev = container_of(work, struct hci_dev,
1346 adv_work.work);
1346 1347
1347 hci_dev_lock(hdev); 1348 hci_dev_lock(hdev);
1348 1349
@@ -1488,9 +1489,8 @@ int hci_register_dev(struct hci_dev *hdev)
1488 INIT_LIST_HEAD(&hdev->remote_oob_data); 1489 INIT_LIST_HEAD(&hdev->remote_oob_data);
1489 1490
1490 INIT_LIST_HEAD(&hdev->adv_entries); 1491 INIT_LIST_HEAD(&hdev->adv_entries);
1491 setup_timer(&hdev->adv_timer, hci_clear_adv_cache,
1492 (unsigned long) hdev);
1493 1492
1493 INIT_DELAYED_WORK(&hdev->adv_work, hci_clear_adv_cache);
1494 INIT_WORK(&hdev->power_on, hci_power_on); 1494 INIT_WORK(&hdev->power_on, hci_power_on);
1495 INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); 1495 INIT_DELAYED_WORK(&hdev->power_off, hci_power_off);
1496 1496
@@ -1576,7 +1576,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
1576 1576
1577 hci_del_sysfs(hdev); 1577 hci_del_sysfs(hdev);
1578 1578
1579 del_timer(&hdev->adv_timer); 1579 cancel_delayed_work_sync(&hdev->adv_work);
1580 1580
1581 destroy_workqueue(hdev->workqueue); 1581 destroy_workqueue(hdev->workqueue);
1582 1582
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 35cb56ed3b0b..0a9501f17366 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1017,7 +1017,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
1017 if (cp->enable == 0x01) { 1017 if (cp->enable == 0x01) {
1018 set_bit(HCI_LE_SCAN, &hdev->dev_flags); 1018 set_bit(HCI_LE_SCAN, &hdev->dev_flags);
1019 1019
1020 del_timer(&hdev->adv_timer); 1020 cancel_delayed_work_sync(&hdev->adv_work);
1021 1021
1022 hci_dev_lock(hdev); 1022 hci_dev_lock(hdev);
1023 hci_adv_entries_clear(hdev); 1023 hci_adv_entries_clear(hdev);
@@ -1025,7 +1025,9 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
1025 } else if (cp->enable == 0x00) { 1025 } else if (cp->enable == 0x00) {
1026 clear_bit(HCI_LE_SCAN, &hdev->dev_flags); 1026 clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
1027 1027
1028 mod_timer(&hdev->adv_timer, jiffies + ADV_CLEAR_TIMEOUT); 1028 cancel_delayed_work_sync(&hdev->adv_work);
1029 queue_delayed_work(hdev->workqueue, &hdev->adv_work,
1030 jiffies + ADV_CLEAR_TIMEOUT);
1029 } 1031 }
1030} 1032}
1031 1033