Re: [PATCH] regmap: define cleanup helper for regmap_field
From: Sander Vanheule
Date: Fri Feb 20 2026 - 10:40:55 EST
Hi Mark,
On Fri, 2026-02-20 at 16:36 +0100, Sander Vanheule wrote:
> For temporary field allocation, the user has to perform manual cleanup,
> or rely on devm_regmap_field_alloc() to (eventually) clean up the
> allocated resources when an error occurs.
>
> Add a cleanup helper that takes care of freeing the allocated
> regmap_field whenever it goes out of scope.
>
> This can simplify this example:
>
> struct regmap_field *field = regmap_field_alloc(...);
> if (!field)
> return -ENOMEM;
The error handling should of course be:
if (IS_ERR(field))
return PTR_ERR(field);
I'll wait a bit for other feedback before I send a v2.
Best,
Sander