diff options
| -rw-r--r-- | include/linux/bitmap.h | 1 | ||||
| -rw-r--r-- | lib/bitmap.c | 22 | 
2 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 89781fd4885..5379913aca5 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,  extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);  extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);  extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order); +extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits);  #define BITMAP_LAST_WORD_MASK(nbits)					\  (									\ diff --git a/lib/bitmap.c b/lib/bitmap.c index 06fb57c86de..c2006bfeea4 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -1007,3 +1007,25 @@ int bitmap_allocate_region(unsigned long *bitmap, int pos, int order)  	return 0;  }  EXPORT_SYMBOL(bitmap_allocate_region); + +/** + * bitmap_copy_le - copy a bitmap, putting the bits into little-endian order. + * @dst:   destination buffer + * @src:   bitmap to copy + * @nbits: number of bits in the bitmap + * + * Require nbits % BITS_PER_LONG == 0. + */ +void bitmap_copy_le(void *dst, const unsigned long *src, int nbits) +{ +	unsigned long *d = dst; +	int i; + +	for (i = 0; i < nbits/BITS_PER_LONG; i++) { +		if (BITS_PER_LONG == 64) +			d[i] = cpu_to_le64(src[i]); +		else +			d[i] = cpu_to_le32(src[i]); +	} +} +EXPORT_SYMBOL(bitmap_copy_le);  |