Return-Path: Date: Mon, 19 Dec 2011 13:05:05 +0200 From: Andrei Emeltchenko To: "Gustavo F. Padovan" Cc: linux-bluetooth@vger.kernel.org Subject: Re: [RFC 06/22] Bluetooth: Move L2CAP timers to workqueue Message-ID: <20111219110504.GD3982@aemeltch-MOBL1> References: <1324157382-1815-1-git-send-email-padovan@profusion.mobi> <1324157382-1815-2-git-send-email-padovan@profusion.mobi> <1324157382-1815-3-git-send-email-padovan@profusion.mobi> <1324157382-1815-4-git-send-email-padovan@profusion.mobi> <1324157382-1815-5-git-send-email-padovan@profusion.mobi> <1324157382-1815-6-git-send-email-padovan@profusion.mobi> <1324157382-1815-7-git-send-email-padovan@profusion.mobi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1324157382-1815-7-git-send-email-padovan@profusion.mobi> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Gustavo, On Sat, Dec 17, 2011 at 07:29:26PM -0200, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" > > 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 > --- > include/net/bluetooth/l2cap.h | 17 +++++----- > net/bluetooth/l2cap_core.c | 70 ++++++++++++++++++----------------------- > 2 files changed, 40 insertions(+), 47 deletions(-) ... > 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