Skip to content

Commit d12a828

Browse files
Bartosz GolaszewskiKAGA-KOKO
authored andcommitted
bitmap: Define a cleanup function for bitmaps
Add support for autopointers for bitmaps allocated with bitmap_alloc() et al. Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Yury Norov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2265324 commit d12a828

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/linux/bitmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/align.h>
88
#include <linux/bitops.h>
9+
#include <linux/cleanup.h>
910
#include <linux/errno.h>
1011
#include <linux/find.h>
1112
#include <linux/limits.h>
@@ -127,6 +128,8 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
127128
unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
128129
void bitmap_free(const unsigned long *bitmap);
129130

131+
DEFINE_FREE(bitmap, unsigned long *, if (_T) bitmap_free(_T))
132+
130133
/* Managed variants of the above. */
131134
unsigned long *devm_bitmap_alloc(struct device *dev,
132135
unsigned int nbits, gfp_t flags);

0 commit comments

Comments
 (0)