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 <[EMAIL PROTECTED]>

Index: linux-2.6-upstream/include/linux/bitmap.h
===================================================================
--- linux-2.6-upstream.orig/include/linux/bitmap.h      2007-08-02 
16:57:40.000000000 +0100
+++ linux-2.6-upstream/include/linux/bitmap.h   2007-08-02 17:00:25.000000000 
+0100
@@ -122,6 +122,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(unsigned long *dst, const unsigned long *src, int 
nbits);
 
 #define BITMAP_LAST_WORD_MASK(nbits)                                   \
 (                                                                      \
Index: linux-2.6-upstream/lib/bitmap.c
===================================================================
--- linux-2.6-upstream.orig/lib/bitmap.c        2007-08-02 16:56:00.000000000 
+0100
+++ linux-2.6-upstream/lib/bitmap.c     2007-08-02 17:32:02.000000000 +0100
@@ -834,3 +834,23 @@
        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);

-- 

Inaky

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to