aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-06-17 12:03:21 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-12-18 14:07:54 -0500
commit19c40e3bcaf2d969f5d4ee85bbe1330b54d36d9c (patch)
treef854037b80d82f59a9b505d2643102b2a51f0629
parent09fd0de5bd8f8ef3317e5365f92f1a13dcd89aa9 (diff)
Bluetooth: Use delayed_work for connection timeout
Bluetooth rx task runs now in a workqueue, so it a good approach run any timer that share locking with process context code also in a workqueue. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/hci_core.h8
-rw-r--r--net/bluetooth/hci_conn.c9
2 files changed, 10 insertions, 7 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e7dbe597a4bb..d91590850429 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -297,7 +297,7 @@ struct hci_conn {
297 struct sk_buff_head data_q; 297 struct sk_buff_head data_q;
298 struct list_head chan_list; 298 struct list_head chan_list;
299 299
300 struct timer_list disc_timer; 300 struct delayed_work disc_work;
301 struct timer_list idle_timer; 301 struct timer_list idle_timer;
302 struct timer_list auto_accept_timer; 302 struct timer_list auto_accept_timer;
303 303
@@ -517,7 +517,7 @@ void hci_conn_put_device(struct hci_conn *conn);
517static inline void hci_conn_hold(struct hci_conn *conn) 517static inline void hci_conn_hold(struct hci_conn *conn)
518{ 518{
519 atomic_inc(&conn->refcnt); 519 atomic_inc(&conn->refcnt);
520 del_timer(&conn->disc_timer); 520 cancel_delayed_work_sync(&conn->disc_work);
521} 521}
522 522
523static inline void hci_conn_put(struct hci_conn *conn) 523static inline void hci_conn_put(struct hci_conn *conn)
@@ -536,7 +536,9 @@ static inline void hci_conn_put(struct hci_conn *conn)
536 } else { 536 } else {
537 timeo = msecs_to_jiffies(10); 537 timeo = msecs_to_jiffies(10);
538 } 538 }
539 mod_timer(&conn->disc_timer, jiffies + timeo); 539 cancel_delayed_work_sync(&conn->disc_work);
540 queue_delayed_work(conn->hdev->workqueue,
541 &conn->disc_work, jiffies + timeo);
540 } 542 }
541} 543}
542 544
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index d45783de5e2a..7d88a6142092 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -275,9 +275,10 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
275 } 275 }
276} 276}
277 277
278static void hci_conn_timeout(unsigned long arg) 278static void hci_conn_timeout(struct work_struct *work)
279{ 279{
280 struct hci_conn *conn = (void *) arg; 280 struct hci_conn *conn = container_of(work, struct hci_conn,
281 disc_work.work);
281 struct hci_dev *hdev = conn->hdev; 282 struct hci_dev *hdev = conn->hdev;
282 __u8 reason; 283 __u8 reason;
283 284
@@ -412,7 +413,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
412 413
413 INIT_LIST_HEAD(&conn->chan_list);; 414 INIT_LIST_HEAD(&conn->chan_list);;
414 415
415 setup_timer(&conn->disc_timer, hci_conn_timeout, (unsigned long)conn); 416 INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
416 setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn); 417 setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
417 setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept, 418 setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept,
418 (unsigned long) conn); 419 (unsigned long) conn);
@@ -444,7 +445,7 @@ int hci_conn_del(struct hci_conn *conn)
444 445
445 del_timer(&conn->idle_timer); 446 del_timer(&conn->idle_timer);
446 447
447 del_timer(&conn->disc_timer); 448 cancel_delayed_work_sync(&conn->disc_work);
448 449
449 del_timer(&conn->auto_accept_timer); 450 del_timer(&conn->auto_accept_timer);
450 451