diff options
author | David Vrabel <david.vrabel@csr.com> | 2008-04-08 13:24:46 -0700 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-04-24 12:39:54 +1000 |
commit | 802a6abd6ed23e3adfc70b0755d426fecca1ccb9 (patch) | |
tree | b5853dd346edf412cb1ab31b81174a172c9405bf /lib | |
parent | c813bd9ddb488a2f0c7d2206a58aaacdbef95d76 (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>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitmap.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index a6939e18d7bb..03d89c450322 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -854,3 +854,23 @@ 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 bitmap. + * @src: bitmap to copy. + * @nbits: number of bits in the bitmap. + * + * Require nbits % BITS_PER_LONG == 0. + */ +void bitmap_copy_le(unsigned long *dst, const unsigned long *src, int nbits) +{ + int i; + + for (i = 0; i < nbits/BITS_PER_LONG; i++) + if (BITS_PER_LONG == 64) + dst[i] = cpu_to_le64(src[i]); + else + dst[i] = cpu_to_le32(src[i]); +} +EXPORT_SYMBOL(bitmap_copy_le); |