From: Bartosz Golaszewski Date: Mon, 22 Jan 2024 12:42:40 +0000 (+0100) Subject: bitmap: Define a cleanup function for bitmaps X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d12a82848eac28d248e67940378fe4a72b0a8cd3;p=linux.git bitmap: Define a cleanup function for bitmaps Add support for autopointers for bitmaps allocated with bitmap_alloc() et al. Signed-off-by: Bartosz Golaszewski Signed-off-by: Thomas Gleixner Reviewed-by: Andy Shevchenko Acked-by: Yury Norov Link: https://lore.kernel.org/r/20240122124243.44002-2-brgl@bgdev.pl --- diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 99451431e4d65..df24c8fb10096 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -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);