lkml.org 
[lkml]   [2008]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] bitmap: add bitmap_copy_le()
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park, Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/
bitmap: add bitmap_copy_le()

From: David Vrabel <david.vrabel@csr.com>

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>
---
include/linux/bitmap.h | 1 +
lib/bitmap.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)

Index: linux-git/include/linux/bitmap.h
===================================================================
--- linux-git.orig/include/linux/bitmap.h 2008-08-12 14:51:02.000000000 +0100
+++ linux-git/include/linux/bitmap.h 2008-08-12 14:51:07.000000000 +0100
@@ -129,6 +129,7 @@
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) \
( \
Index: linux-git/lib/bitmap.c
===================================================================
--- linux-git.orig/lib/bitmap.c 2008-08-12 14:51:02.000000000 +0100
+++ linux-git/lib/bitmap.c 2008-08-12 14:51:07.000000000 +0100
@@ -996,3 +996,25 @@
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);
\
 
 \ /
  Last update: 2008-08-21 15:23    [W:0.114 / U:0.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site