From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030852AbXCHWuv (ORCPT ); Thu, 8 Mar 2007 17:50:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030843AbXCHWut (ORCPT ); Thu, 8 Mar 2007 17:50:49 -0500 Received: from mx1.redhat.com ([66.187.233.31]:35761 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030812AbXCHWue (ORCPT ); Thu, 8 Mar 2007 17:50:34 -0500 From: David Howells Subject: [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work To: davem@davemloft.net, netdev@vger.kernel.org, herbert.xu@redhat.com Cc: linux-kernel@vger.kernel.org, hch@infradead.org, arjan@infradead.org, dhowells@redhat.com Date: Thu, 08 Mar 2007 22:48:54 +0000 Message-ID: <20070308224854.17456.71874.stgit@warthog.cambridge.redhat.com> In-Reply-To: <20070308224806.17456.13944.stgit@warthog.cambridge.redhat.com> References: <20070308224806.17456.13944.stgit@warthog.cambridge.redhat.com> User-Agent: StGIT/0.12.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Export try_to_del_timer_sync() for use by the RxRPC module. Add a try_to_cancel_delayed_work() so that it is possible to merely attempt to cancel a delayed work timer. Signed-Off-By: David Howells --- include/linux/workqueue.h | 21 +++++++++++++++++++++ kernel/timer.c | 2 ++ 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 2a7b38d..40a61ae 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -204,4 +204,25 @@ static inline int cancel_delayed_work(struct delayed_work *work) return ret; } +/** + * try_to_cancel_delayed_work - Try to kill pending scheduled, delayed work + * @work: the work to cancel + * + * Try to kill off a pending schedule_delayed_work(). + * - The timer may still be running afterwards, and if so, the work may still + * be pending + * - Returns -1 if timer still active, 1 if timer removed, 0 if not scheduled + * - Can be called from the work routine; if it's still pending, just return + * and it'll be called again. + */ +static inline int try_to_cancel_delayed_work(struct delayed_work *work) +{ + int ret; + + ret = try_to_del_timer_sync(&work->timer); + if (ret > 0) + work_release(&work->work); + return ret; +} + #endif diff --git a/kernel/timer.c b/kernel/timer.c index 797cccb..447506a 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -505,6 +505,8 @@ out: return ret; } +EXPORT_SYMBOL(try_to_del_timer_sync); + /** * del_timer_sync - deactivate a timer and wait for the handler to finish. * @timer: the timer to be deactivated