diff options
author | Jens Axboe <axboe@fb.com> | 2016-08-24 15:51:50 -0600 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-23 23:43:33 +0200 |
commit | 541b9f854f466ae2578a52d1ec1d07eaec2d5d50 (patch) | |
tree | 165efe294b124cf2f5d6ffb60dbe306a531b6753 /kernel/workqueue.c | |
parent | 5e5d8b8926a2421f35b12cda8275c73648202e3f (diff) |
workqueue: add cancel_work()
Like cancel_delayed_work(), but for regular work.
Change-Id: Ic967cb1616245b71a63e1b92f8e28d94a27ae490
Signed-off-by: Jens Axboe <axboe@fb.com>
Mehed-by: Tejun Heo <tj@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 89a0f1171f90..595701736334 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2919,6 +2919,31 @@ bool flush_delayed_work(struct delayed_work *dwork) } EXPORT_SYMBOL(flush_delayed_work); +static bool __cancel_work(struct work_struct *work, bool is_dwork) +{ + unsigned long flags; + int ret; + + do { + ret = try_to_grab_pending(work, is_dwork, &flags); + } while (unlikely(ret == -EAGAIN)); + + if (unlikely(ret < 0)) + return false; + + set_work_pool_and_clear_pending(work, get_work_pool_id(work)); + local_irq_restore(flags); + return ret; +} + +/* + * See cancel_delayed_work() + */ +bool cancel_work(struct work_struct *work) +{ + return __cancel_work(work, false); +} + /** * cancel_delayed_work - cancel a delayed work * @dwork: delayed_work to cancel @@ -2937,20 +2962,7 @@ EXPORT_SYMBOL(flush_delayed_work); */ bool cancel_delayed_work(struct delayed_work *dwork) { - unsigned long flags; - int ret; - - do { - ret = try_to_grab_pending(&dwork->work, true, &flags); - } while (unlikely(ret == -EAGAIN)); - - if (unlikely(ret < 0)) - return false; - - set_work_pool_and_clear_pending(&dwork->work, - get_work_pool_id(&dwork->work)); - local_irq_restore(flags); - return ret; + return __cancel_work(&dwork->work, true); } EXPORT_SYMBOL(cancel_delayed_work); |