Re: [RFC 06/22] Bluetooth: Move L2CAP timers to workqueue
From: Andrei Emeltchenko <hidden>
Date: 2011-12-19 11:05:05
Hi Gustavo, On Sat, Dec 17, 2011 at 07:29:26PM -0200, Gustavo F. Padovan wrote:
From: "Gustavo F. Padovan" <redacted> L2CAP timers also need to run in process context. As the works in l2cap are small we are using the system worqueue. Signed-off-by: Gustavo F. Padovan <redacted> --- include/net/bluetooth/l2cap.h | 17 +++++----- net/bluetooth/l2cap_core.c | 70 ++++++++++++++++++----------------------- 2 files changed, 40 insertions(+), 47 deletions(-)
...
quoted hunk ↗ jump to hunk
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0369a9b..89cda6d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c@@ -213,20 +213,18 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) return 0; } -static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, long timeout) +static void l2cap_set_timer(struct l2cap_chan *chan, struct delayed_work *work, long timeout) { BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); - if (!mod_timer(timer, jiffies + msecs_to_jiffies(timeout))) - chan_hold(chan); + cancel_delayed_work_sync(work); + + schedule_delayed_work(work, timeout); } -static void l2cap_clear_timer(struct l2cap_chan *chan, struct timer_list *timer) +static void l2cap_clear_timer(struct delayed_work *work) { - BT_DBG("chan %p state %d", chan, chan->state); - - if (timer_pending(timer) && del_timer(timer)) - chan_put(chan); + cancel_delayed_work_sync(work); }
Do you think we do not need to use chan_hold / chan_put? Best regards Andrei Emeltchenko