diff options
author | David Vrabel <david.vrabel@csr.com> | 2008-09-17 11:34:03 -0400 |
---|---|---|
committer | David Vrabel <dv02@dv02pc01.europe.root.pri> | 2008-09-17 11:54:22 -0400 |
commit | ccbe329bcd87924baed96474ec0a6725e3957897 (patch) | |
tree | 7d1f2737916d85aae76e54ab0fefff816fdf4316 /lib/bitmap.c | |
parent | 45e9c0de2e86485f8b6633fd64ab19cfbff167f6 (diff) |
bitmap: add bitmap_copy_le()
bitmap_copy_le() copies a bitmap, putting the bits into little-endian
order (i.e., each unsigned long word in the bitmap is put into
little-endian order).
The UWB stack used bitmaps to manage Medium Access Slot availability,
and these bitmaps need to be written to the hardware in LE order.
Signed-off-by: David Vrabel <david.vrabel@csr.com>
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 22 |
1 files changed, 22 insertions, 0 deletions
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 | } |
1009 | EXPORT_SYMBOL(bitmap_allocate_region); | 1009 | EXPORT_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 | */ | ||
1019 | void 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 | } | ||
1031 | EXPORT_SYMBOL(bitmap_copy_le); | ||