diff options
| author | Tzung-Bi Shih <tzungbi@kernel.org> | 2026-03-20 02:52:03 +0000 |
|---|---|---|
| committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2026-03-20 02:54:24 +0000 |
| commit | c98f7d6ac39fed778a425c0ca18b002f6ee5a77a (patch) | |
| tree | cc97840978443a8f69306639b9e2b42758f5ca2f /kernel | |
| parent | 27d58498f690ab39140678df918155a597b3a17a (diff) | |
| parent | 1dfc9d60a69ec148e1cb709256617d86e5f0e8f8 (diff) | |
Merge remote-tracking branch 'wq/for-7.1-devm-alloc-wq'
Merge branch adding support for device-managed workqueue allocation,
which allows cleaning up a chrome-platform driver.
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/workqueue.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index aeaec79bc09c..19d20f3039d9 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -41,6 +41,7 @@ #include <linux/mempolicy.h> #include <linux/freezer.h> #include <linux/debug_locks.h> +#include <linux/device/devres.h> #include <linux/lockdep.h> #include <linux/idr.h> #include <linux/jhash.h> @@ -5891,6 +5892,33 @@ struct workqueue_struct *alloc_workqueue_noprof(const char *fmt, } EXPORT_SYMBOL_GPL(alloc_workqueue_noprof); +static void devm_workqueue_release(void *res) +{ + destroy_workqueue(res); +} + +__printf(2, 5) struct workqueue_struct * +devm_alloc_workqueue(struct device *dev, const char *fmt, unsigned int flags, + int max_active, ...) +{ + struct workqueue_struct *wq; + va_list args; + int ret; + + va_start(args, max_active); + wq = alloc_workqueue(fmt, flags, max_active, args); + va_end(args); + if (!wq) + return NULL; + + ret = devm_add_action_or_reset(dev, devm_workqueue_release, wq); + if (ret) + return NULL; + + return wq; +} +EXPORT_SYMBOL_GPL(devm_alloc_workqueue); + #ifdef CONFIG_LOCKDEP __printf(1, 5) struct workqueue_struct * |
