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 <dhowells@xxxxxxxxxx> --- 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 440048a..ba4d6e0 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 - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html