summaryrefslogtreecommitdiffstats
path: root/include/linux/bitmap.h
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2024-01-22 13:42:40 +0100
committerThomas Gleixner <tglx@linutronix.de>2024-01-26 13:44:48 +0100
commitd12a82848eac28d248e67940378fe4a72b0a8cd3 (patch)
tree39d6a757d6e9c44ad32545587aedb6c776105bff /include/linux/bitmap.h
parent22653244a9fed06f2f864b44808a85bf5c4e3ef2 (diff)
downloadlinux-stable-d12a82848eac28d248e67940378fe4a72b0a8cd3.tar.gz
linux-stable-d12a82848eac28d248e67940378fe4a72b0a8cd3.tar.bz2
linux-stable-d12a82848eac28d248e67940378fe4a72b0a8cd3.zip
bitmap: Define a cleanup function for bitmaps
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
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r--include/linux/bitmap.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 99451431e4d6..df24c8fb1009 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>
@@ -127,6 +128,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);