aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/bitmap.h1
-rw-r--r--lib/bitmap.c22
2 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 89781fd48859..5379913aca52 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -130,6 +130,7 @@ extern void bitmap_fold(unsigned long *dst, const unsigned long *orig,
130extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order); 130extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
131extern void bitmap_release_region(unsigned long *bitmap, int pos, int order); 131extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
132extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order); 132extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
133extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits);
133 134
134#define BITMAP_LAST_WORD_MASK(nbits) \ 135#define BITMAP_LAST_WORD_MASK(nbits) \
135( \ 136( \
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 06fb57c86de0..c2006bfeea41 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -1007,3 +1007,25 @@ int bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
1007 return 0; 1007 return 0;
1008} 1008}
1009EXPORT_SYMBOL(bitmap_allocate_region); 1009EXPORT_SYMBOL(bitmap_allocate_region);
1010
1011/**
1012 * bitmap_copy_le - copy a bitmap, putting the bits into little-endian order.
1013 * @dst: destination buffer
1014 * @src: bitmap to copy
1015 * @nbits: number of bits in the bitmap
1016 *
1017 * Require nbits % BITS_PER_LONG == 0.
1018 */
1019void bitmap_copy_le(void *dst, const unsigned long *src, int nbits)
1020{
1021 unsigned long *d = dst;
1022 int i;
1023
1024 for (i = 0; i < nbits/BITS_PER_LONG; i++) {
1025 if (BITS_PER_LONG == 64)
1026 d[i] = cpu_to_le64(src[i]);
1027 else
1028 d[i] = cpu_to_le32(src[i]);
1029 }
1030}
1031EXPORT_SYMBOL(bitmap_copy_le);