aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-06-16 06:30:56 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-03 11:42:42 -0400
commit65cc2b49db63adf1455a9783234383fbec5b8314 (patch)
tree880d1d7ae9174088692e8f4d694a265af2a9e570 /net/bluetooth
parentd9fbd02be5c201c1659ee0d79c0820bb68d95c8c (diff)
Bluetooth: Use struct delayed_work for HCI command timeout
Since the whole HCI command, event and data packet processing has been migrated to use workqueues instead of tasklets, it makes sense to use struct delayed_work instead of struct timer_list for the timeout handling. This patch converts the hdev->cmd_timer to use workqueue as well. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c17
-rw-r--r--net/bluetooth/hci_event.c4
2 files changed, 11 insertions, 10 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0a43cce9a914..9e0368b02a11 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2432,7 +2432,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
2432 hci_req_lock(hdev); 2432 hci_req_lock(hdev);
2433 2433
2434 if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { 2434 if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
2435 del_timer_sync(&hdev->cmd_timer); 2435 cancel_delayed_work_sync(&hdev->cmd_timer);
2436 hci_req_unlock(hdev); 2436 hci_req_unlock(hdev);
2437 return 0; 2437 return 0;
2438 } 2438 }
@@ -2488,7 +2488,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
2488 2488
2489 /* Drop last sent command */ 2489 /* Drop last sent command */
2490 if (hdev->sent_cmd) { 2490 if (hdev->sent_cmd) {
2491 del_timer_sync(&hdev->cmd_timer); 2491 cancel_delayed_work_sync(&hdev->cmd_timer);
2492 kfree_skb(hdev->sent_cmd); 2492 kfree_skb(hdev->sent_cmd);
2493 hdev->sent_cmd = NULL; 2493 hdev->sent_cmd = NULL;
2494 } 2494 }
@@ -3205,9 +3205,10 @@ void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type)
3205} 3205}
3206 3206
3207/* HCI command timer function */ 3207/* HCI command timer function */
3208static void hci_cmd_timeout(unsigned long arg) 3208static void hci_cmd_timeout(struct work_struct *work)
3209{ 3209{
3210 struct hci_dev *hdev = (void *) arg; 3210 struct hci_dev *hdev = container_of(work, struct hci_dev,
3211 cmd_timer.work);
3211 3212
3212 if (hdev->sent_cmd) { 3213 if (hdev->sent_cmd) {
3213 struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; 3214 struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data;
@@ -3884,7 +3885,7 @@ struct hci_dev *hci_alloc_dev(void)
3884 3885
3885 init_waitqueue_head(&hdev->req_wait_q); 3886 init_waitqueue_head(&hdev->req_wait_q);
3886 3887
3887 setup_timer(&hdev->cmd_timer, hci_cmd_timeout, (unsigned long) hdev); 3888 INIT_DELAYED_WORK(&hdev->cmd_timer, hci_cmd_timeout);
3888 3889
3889 hci_init_sysfs(hdev); 3890 hci_init_sysfs(hdev);
3890 discovery_init(hdev); 3891 discovery_init(hdev);
@@ -5287,10 +5288,10 @@ static void hci_cmd_work(struct work_struct *work)
5287 atomic_dec(&hdev->cmd_cnt); 5288 atomic_dec(&hdev->cmd_cnt);
5288 hci_send_frame(hdev, skb); 5289 hci_send_frame(hdev, skb);
5289 if (test_bit(HCI_RESET, &hdev->flags)) 5290 if (test_bit(HCI_RESET, &hdev->flags))
5290 del_timer(&hdev->cmd_timer); 5291 cancel_delayed_work(&hdev->cmd_timer);
5291 else 5292 else
5292 mod_timer(&hdev->cmd_timer, 5293 schedule_delayed_work(&hdev->cmd_timer,
5293 jiffies + HCI_CMD_TIMEOUT); 5294 HCI_CMD_TIMEOUT);
5294 } else { 5295 } else {
5295 skb_queue_head(&hdev->cmd_q, skb); 5296 skb_queue_head(&hdev->cmd_q, skb);
5296 queue_work(hdev->workqueue, &hdev->cmd_work); 5297 queue_work(hdev->workqueue, &hdev->cmd_work);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 640c54ec1bd2..3d52be1d695d 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2709,7 +2709,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
2709 } 2709 }
2710 2710
2711 if (opcode != HCI_OP_NOP) 2711 if (opcode != HCI_OP_NOP)
2712 del_timer(&hdev->cmd_timer); 2712 cancel_delayed_work(&hdev->cmd_timer);
2713 2713
2714 hci_req_cmd_complete(hdev, opcode, status); 2714 hci_req_cmd_complete(hdev, opcode, status);
2715 2715
@@ -2800,7 +2800,7 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
2800 } 2800 }
2801 2801
2802 if (opcode != HCI_OP_NOP) 2802 if (opcode != HCI_OP_NOP)
2803 del_timer(&hdev->cmd_timer); 2803 cancel_delayed_work(&hdev->cmd_timer);
2804 2804
2805 if (ev->status || 2805 if (ev->status ||
2806 (hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req.event)) 2806 (hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req.event))