Thread (25 messages) 25 messages, 6 authors, 2026-03-05

Re: [PATCH 1/9] workqueue: devres: Add device-managed allocate workqueue

From: Krzysztof Kozlowski <krzk@kernel.org>
Date: 2026-02-23 11:43:50
Also in: chrome-platform, driver-core, linux-doc, linux-mediatek, linux-pm, lkml

On 23/02/2026 12:34, Andy Shevchenko wrote:
On Mon, Feb 23, 2026 at 11:18:41AM +0100, Krzysztof Kozlowski wrote:
quoted
On 23/02/2026 09:56, Andy Shevchenko wrote:
quoted
On Mon, Feb 23, 2026 at 08:27:29AM +0100, Krzysztof Kozlowski wrote:
...
quoted
quoted
quoted
+	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help