aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r--lib/bitmap.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 58f9750e49c6..730969c681cb 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -13,6 +13,7 @@
13#include <linux/bitops.h> 13#include <linux/bitops.h>
14#include <linux/bug.h> 14#include <linux/bug.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/slab.h>
16#include <linux/string.h> 17#include <linux/string.h>
17#include <linux/uaccess.h> 18#include <linux/uaccess.h>
18 19
@@ -1125,6 +1126,25 @@ void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int n
1125EXPORT_SYMBOL(bitmap_copy_le); 1126EXPORT_SYMBOL(bitmap_copy_le);
1126#endif 1127#endif
1127 1128
1129unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags)
1130{
1131 return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long),
1132 flags);
1133}
1134EXPORT_SYMBOL(bitmap_alloc);
1135
1136unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags)
1137{
1138 return bitmap_alloc(nbits, flags | __GFP_ZERO);
1139}
1140EXPORT_SYMBOL(bitmap_zalloc);
1141
1142void bitmap_free(const unsigned long *bitmap)
1143{
1144 kfree(bitmap);
1145}
1146EXPORT_SYMBOL(bitmap_free);
1147
1128#if BITS_PER_LONG == 64 1148#if BITS_PER_LONG == 64
1129/** 1149/**
1130 * bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap 1150 * bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap