diff options
| author | riastradh <riastradh@NetBSD.org> | 2021-12-19 01:03:57 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2021-12-19 01:03:57 +0000 |
| commit | dc2cdb28140a60a366ebcfbf9a40d14a741f163a (patch) | |
| tree | f2b2a0a1ed353a68e5068e97ef5d854077c5f9f1 /sys/external/bsd/common/linux/linux_work.c | |
| parent | b8227669ffa0652eb6ef226a5a736100eb778fd8 (diff) | |
Implement return value of flush_work, flush_delayed_work.
Diffstat (limited to 'sys/external/bsd/common/linux/linux_work.c')
| -rw-r--r-- | sys/external/bsd/common/linux/linux_work.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/external/bsd/common/linux/linux_work.c b/sys/external/bsd/common/linux/linux_work.c index 13334427fcd..b3ef9e16132 100644 --- a/sys/external/bsd/common/linux/linux_work.c +++ b/sys/external/bsd/common/linux/linux_work.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_work.c,v 1.47 2021/12/19 00:49:00 riastradh Exp $ */ +/* $NetBSD: linux_work.c,v 1.48 2021/12/19 01:03:57 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.47 2021/12/19 00:49:00 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.48 2021/12/19 01:03:57 riastradh Exp $"); #include <sys/types.h> #include <sys/atomic.h> @@ -1430,17 +1430,21 @@ flush_workqueue(struct workqueue_struct *wq) * * If work is queued or currently executing, wait for it to * complete. + * + * Return true if we waited to flush it, false if it was already + * idle. */ -void +bool flush_work(struct work_struct *work) { struct workqueue_struct *wq; /* If there's no workqueue, nothing to flush. */ if ((wq = work_queue(work)) == NULL) - return; + return false; flush_workqueue(wq); + return true; } /* @@ -1450,14 +1454,15 @@ flush_work(struct work_struct *work) * instead. Then, if dw is queued or currently executing, wait * for it to complete. */ -void +bool flush_delayed_work(struct delayed_work *dw) { struct workqueue_struct *wq; + bool waited = false; /* If there's no workqueue, nothing to flush. */ if ((wq = work_queue(&dw->work)) == NULL) - return; + return false; mutex_enter(&wq->wq_lock); if (__predict_false(work_queue(&dw->work) != wq)) { @@ -1466,6 +1471,7 @@ flush_delayed_work(struct delayed_work *dw) * queue, though that would be ill-advised), so it must * have completed, and we have nothing more to do. */ + waited = false; } else { switch (dw->dw_state) { case DELAYED_WORK_IDLE: @@ -1514,6 +1520,9 @@ flush_delayed_work(struct delayed_work *dw) * but doesn't hurt. */ flush_workqueue_locked(wq); + waited = true; } mutex_exit(&wq->wq_lock); + + return waited; } |
