[tip: irq/core] bitmap: Define a cleanup function for bitmaps
From: tip-bot2 for Bartosz Golaszewski
Date: Fri Jan 26 2024 - 07:54:04 EST
The following commit has been merged into the irq/core branch of tip:
Commit-ID: d12a82848eac28d248e67940378fe4a72b0a8cd3
Gitweb: https://git.kernel.org/tip/d12a82848eac28d248e67940378fe4a72b0a8cd3
Author: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
AuthorDate: Mon, 22 Jan 2024 13:42:40 +01:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitterDate: Fri, 26 Jan 2024 13:44:48 +01:00
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@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Acked-by: Yury Norov <yury.norov@xxxxxxxxx>
Link: https://lore.kernel.org/r/20240122124243.44002-2-brgl@xxxxxxxx
---
include/linux/bitmap.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 9945143..df24c8f 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);