* [PATCH v2 1/2] regmap: sort header includes
@ 2026-02-20 16:01 Sander Vanheule
2026-02-20 16:01 ` [PATCH v2 2/2] regmap: define cleanup helper for regmap_field Sander Vanheule
2026-02-25 19:07 ` [PATCH v2 1/2] regmap: sort header includes Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Sander Vanheule @ 2026-02-20 16:01 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Sander Vanheule
Sort the included headers to make spotting duplicates easier and avoid
discussions on where to add new includes.
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
New patch since v2
---
include/linux/regmap.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index caff2240bdab..c8a6a05bdba1 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -10,15 +10,15 @@
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
*/
-#include <linux/list.h>
-#include <linux/rbtree.h>
-#include <linux/ktime.h>
+#include <linux/bug.h>
#include <linux/delay.h>
#include <linux/err.h>
-#include <linux/bug.h>
-#include <linux/lockdep.h>
-#include <linux/iopoll.h>
#include <linux/fwnode.h>
+#include <linux/iopoll.h>
+#include <linux/ktime.h>
+#include <linux/list.h>
+#include <linux/lockdep.h>
+#include <linux/rbtree.h>
struct module;
struct clk;
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] regmap: define cleanup helper for regmap_field
2026-02-20 16:01 [PATCH v2 1/2] regmap: sort header includes Sander Vanheule
@ 2026-02-20 16:01 ` Sander Vanheule
2026-02-25 19:07 ` [PATCH v2 1/2] regmap: sort header includes Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Sander Vanheule @ 2026-02-20 16:01 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Sander Vanheule
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 (IS_ERR(field))
return PTR_ERR(field);
int err = regmap_field_read(...);
if (err)
goto out;
/* some logic that may also error */
err = regmap_field_write(...);
out:
regmap_field_free(field);
return err;
into the shorter:
struct regmap_field *field __free(regmap_field) = regmap_field_alloc(...);
if (IS_ERR(field))
return PTR_ERR(field);
int err = regmap_field_read(...);
if (err)
return err;
/* some logic that may also error */
return regmap_field_write(...);
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
Changes since v1:
- Fix error handling of regmap_field_alloc() in example
- Make example less trivial
---
include/linux/regmap.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index c8a6a05bdba1..f1c5cb63c171 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -11,6 +11,7 @@
*/
#include <linux/bug.h>
+#include <linux/cleanup.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/fwnode.h>
@@ -1460,6 +1461,8 @@ struct regmap_field *regmap_field_alloc(struct regmap *regmap,
struct reg_field reg_field);
void regmap_field_free(struct regmap_field *field);
+DEFINE_FREE(regmap_field, struct regmap_field *, if (_T) regmap_field_free(_T))
+
struct regmap_field *devm_regmap_field_alloc(struct device *dev,
struct regmap *regmap, struct reg_field reg_field);
void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] regmap: sort header includes
2026-02-20 16:01 [PATCH v2 1/2] regmap: sort header includes Sander Vanheule
2026-02-20 16:01 ` [PATCH v2 2/2] regmap: define cleanup helper for regmap_field Sander Vanheule
@ 2026-02-25 19:07 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-02-25 19:07 UTC (permalink / raw)
To: Sander Vanheule; +Cc: linux-kernel
On Fri, 20 Feb 2026 17:01:11 +0100, Sander Vanheule wrote:
> Sort the included headers to make spotting duplicates easier and avoid
> discussions on where to add new includes.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/2] regmap: sort header includes
commit: 38ab6557234d8629407a824be90e82514d6129a0
[2/2] regmap: define cleanup helper for regmap_field
commit: 37983fad7f3ef296fa0504c8e945987459dc5487
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-25 19:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-20 16:01 [PATCH v2 1/2] regmap: sort header includes Sander Vanheule
2026-02-20 16:01 ` [PATCH v2 2/2] regmap: define cleanup helper for regmap_field Sander Vanheule
2026-02-25 19:07 ` [PATCH v2 1/2] regmap: sort header includes Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome