[PATCH 1/9] workqueue: devres: Add device-managed allocate workqueue
Krzysztof Kozlowski
krzk at kernel.org
Mon Feb 23 03:43:42 PST 2026
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(struct device *dev, 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, ..., 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.
Best regards,
Krzysztof
More information about the linux-arm-kernel
mailing list