From: David Vrabel <david.vrabel@csr.com>
To: Kernel development list <linux-kernel@vger.kernel.org>
Cc: linux-usb <linux-usb@vger.kernel.org>, torvalds@linux-foundation.org
Subject: [patch] bitmap: add bitmap_copy_le()
Date: Thu, 21 Aug 2008 14:19:06 +0100 [thread overview]
Message-ID: <48AD6B4A.1020803@csr.com> (raw)
In-Reply-To: <48AD6AF0.3050504@csr.com>
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
--
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/
[-- Attachment #2: bitmap-add-bitmap_copy_le.patch --]
[-- Type: text/x-diff, Size: 2140 bytes --]
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);
next prev parent reply other threads:[~2008-08-21 13:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-21 13:17 New subsystems: Ultra-Wideband radio, Wireless USB and WiMedia LLC Protocol David Vrabel
2008-08-21 13:19 ` David Vrabel [this message]
2008-08-21 13:20 ` [patch] Add helper macros for little-endian bitfields David Vrabel
2008-08-25 1:37 ` Roland Dreier
2008-08-25 1:43 ` Al Viro
2008-08-27 15:20 ` David Vrabel
2008-08-27 21:19 ` Jeremy Fitzhardinge
2008-08-27 21:26 ` Linus Torvalds
2008-08-21 14:21 ` New subsystems: Ultra-Wideband radio, Wireless USB and WiMedia LLC Protocol Sam Ravnborg
2008-08-21 19:01 ` Sam Ravnborg
2008-08-21 15:43 ` Greg KH
2008-09-17 16:20 ` David Vrabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48AD6B4A.1020803@csr.com \
--to=david.vrabel@csr.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox