[PATCH 1/9] workqueue: devres: Add device-managed allocate workqueue
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Mon Feb 23 03:48:45 PST 2026
On Mon, Feb 23, 2026 at 12:43:42PM +0100, Krzysztof Kozlowski wrote:
> On 23/02/2026 12:34, Andy Shevchenko wrote:
> > On Mon, Feb 23, 2026 at 11:18:41AM +0100, Krzysztof Kozlowski wrote:
> >> On 23/02/2026 09:56, Andy Shevchenko wrote:
> >>> On Mon, Feb 23, 2026 at 08:27:29AM +0100, Krzysztof Kozlowski wrote:
...
> >>>> + ptr = devres_alloc(devm_destroy_workqueue, sizeof(*ptr), GFP_KERNEL);
> >>>> + if (!ptr)
> >>>> + return NULL;
> >>>> +
> >>>> + va_start(args, max_active);
> >>>> + wq = alloc_workqueue(fmt, flags, max_active, args);
> >>>> + va_end(args);
> >>>> + if (wq) {
> >>>> + *ptr = wq;
> >>>> + devres_add(dev, ptr);
> >>>> + } else {
> >>>> + devres_free(ptr);
> >>>> + }
> >>>
> >>> Why not using devm_add_action_or_reset()?
> >>
> >> Where? Here? How the code would be simpler, exactly?
> >
> > static void devm_workqueue_release(void *wq)
> > {
> > destroy_workqueue(wq);
> > }
> > ...
> > {
> > ...
> >
> > va_start(args, max_active);
> > wq = alloc_workqueue(fmt, flags, max_active, args);
> > va_end(args);
> > if (!wq)
> > return NULL; // or ERR_PTR(-ENOMEM) on your choice
> >
> > ret = devm_add_action_or_reset(dev, devm_workqueue_release, wq);
> > if (ret)
> > return NULL; // ERR_PTR(ret) on your choice
> >
> > return wq;
> > }
> >
> > Compare to yours :-)
>
> Ah, so dropping the devres_alloc()? Yeah, that would be simpler.
Yep! The side effect is dropping that ugly casting in _release() along with
unused dev.
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list