diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2009-12-15 19:48:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 10:20:18 -0500 |
commit | c1a2a962a2ad103846e7950b4591471fabecece7 (patch) | |
tree | 9a06ab8d1c65037456bad02c821033197f67f03f /include/linux/bitmap.h | |
parent | 868d64812ae84e8f094e0bcf95157c7d79d625ec (diff) |
bitmap: introduce bitmap_set, bitmap_clear, bitmap_find_next_zero_area
This introduces new bitmap functions:
bitmap_set: Set specified bit area
bitmap_clear: Clear specified bit area
bitmap_find_next_zero_area: Find free bit area
These are mostly stolen from iommu helper. The differences are:
- Use find_next_bit instead of doing test_bit for each bit
- Rewrite bitmap_set and bitmap_clear
Instead of setting or clearing for each bit.
- Check the last bit of the limit
iommu-helper doesn't want to find such area
- The return value if there is no zero area
find_next_zero_area in iommu helper: returns -1
bitmap_find_next_zero_area: return >= bitmap size
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Lothar Wassmann <LW@KARO-electronics.de>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r-- | include/linux/bitmap.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 756d78b8c1c5..daf8c480c786 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -42,6 +42,9 @@ | |||
42 | * bitmap_empty(src, nbits) Are all bits zero in *src? | 42 | * bitmap_empty(src, nbits) Are all bits zero in *src? |
43 | * bitmap_full(src, nbits) Are all bits set in *src? | 43 | * bitmap_full(src, nbits) Are all bits set in *src? |
44 | * bitmap_weight(src, nbits) Hamming Weight: number set bits | 44 | * bitmap_weight(src, nbits) Hamming Weight: number set bits |
45 | * bitmap_set(dst, pos, nbits) Set specified bit area | ||
46 | * bitmap_clear(dst, pos, nbits) Clear specified bit area | ||
47 | * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area | ||
45 | * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n | 48 | * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n |
46 | * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n | 49 | * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n |
47 | * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) | 50 | * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) |
@@ -108,6 +111,14 @@ extern int __bitmap_subset(const unsigned long *bitmap1, | |||
108 | const unsigned long *bitmap2, int bits); | 111 | const unsigned long *bitmap2, int bits); |
109 | extern int __bitmap_weight(const unsigned long *bitmap, int bits); | 112 | extern int __bitmap_weight(const unsigned long *bitmap, int bits); |
110 | 113 | ||
114 | extern void bitmap_set(unsigned long *map, int i, int len); | ||
115 | extern void bitmap_clear(unsigned long *map, int start, int nr); | ||
116 | extern unsigned long bitmap_find_next_zero_area(unsigned long *map, | ||
117 | unsigned long size, | ||
118 | unsigned long start, | ||
119 | unsigned int nr, | ||
120 | unsigned long align_mask); | ||
121 | |||
111 | extern int bitmap_scnprintf(char *buf, unsigned int len, | 122 | extern int bitmap_scnprintf(char *buf, unsigned int len, |
112 | const unsigned long *src, int nbits); | 123 | const unsigned long *src, int nbits); |
113 | extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, | 124 | extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, |