diff mbox series

[SRU,N,02/14] bitmap: Define a cleanup function for bitmaps

Message ID 260ed3b9ee6d29d616773cac185b975d1582ecd7.1744350640.git.koichiro.den@canonical.com
State New
Headers show
Series Introduce configfs-based interface for gpio-aggregator (LP: #2103496) | expand

Commit Message

Koichiro Den April 11, 2025, 7:26 a.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

BugLink: https://bugs.launchpad.net/bugs/2103496

Add support for autopointers for bitmaps allocated with bitmap_alloc()
et al.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Yury Norov <yury.norov@gmail.com>
Link: https://lore.kernel.org/r/20240122124243.44002-2-brgl@bgdev.pl
(cherry picked from commit d12a82848eac28d248e67940378fe4a72b0a8cd3)
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
---
 include/linux/bitmap.h | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 2a71bb3f2454..d7ffed3353f8 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -6,6 +6,7 @@ 
 
 #include <linux/align.h>
 #include <linux/bitops.h>
+#include <linux/cleanup.h>
 #include <linux/errno.h>
 #include <linux/find.h>
 #include <linux/limits.h>
@@ -131,6 +132,8 @@  unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
 unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
 void bitmap_free(const unsigned long *bitmap);
 
+DEFINE_FREE(bitmap, unsigned long *, if (_T) bitmap_free(_T))
+
 /* Managed variants of the above. */
 unsigned long *devm_bitmap_alloc(struct device *dev,
 				 unsigned int nbits, gfp_t flags);