diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2014-08-06 19:10:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-06 21:01:26 -0400 |
commit | 154f5e38f30f262025c8c2e825376f6eb51e8bcb (patch) | |
tree | 2b9850d703dfe9d0a7dca3748f7f4781f9a6c3b2 | |
parent | fb5ac54263ef3fcb5c469a61e0ab6b06e45e2307 (diff) |
lib: bitmap: make the start index of bitmap_clear unsigned
The compiler can generate slightly smaller and simpler code when it
knows that "start" is non-negative.
Also, use the names "start" and "len" for the two parameters for
consistency with bitmap_set.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/bitmap.h | 2 | ||||
-rw-r--r-- | lib/bitmap.c | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index ad2c67d3583e..83c1c7d25073 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -113,7 +113,7 @@ extern int __bitmap_subset(const unsigned long *bitmap1, | |||
113 | extern int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); | 113 | extern int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); |
114 | 114 | ||
115 | extern void bitmap_set(unsigned long *map, unsigned int start, int len); | 115 | extern void bitmap_set(unsigned long *map, unsigned int start, int len); |
116 | extern void bitmap_clear(unsigned long *map, int start, int nr); | 116 | extern void bitmap_clear(unsigned long *map, unsigned int start, int len); |
117 | extern unsigned long bitmap_find_next_zero_area(unsigned long *map, | 117 | extern unsigned long bitmap_find_next_zero_area(unsigned long *map, |
118 | unsigned long size, | 118 | unsigned long size, |
119 | unsigned long start, | 119 | unsigned long start, |
diff --git a/lib/bitmap.c b/lib/bitmap.c index 2a3a92fc3355..5d2540396300 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -295,21 +295,21 @@ void bitmap_set(unsigned long *map, unsigned int start, int len) | |||
295 | } | 295 | } |
296 | EXPORT_SYMBOL(bitmap_set); | 296 | EXPORT_SYMBOL(bitmap_set); |
297 | 297 | ||
298 | void bitmap_clear(unsigned long *map, int start, int nr) | 298 | void bitmap_clear(unsigned long *map, unsigned int start, int len) |
299 | { | 299 | { |
300 | unsigned long *p = map + BIT_WORD(start); | 300 | unsigned long *p = map + BIT_WORD(start); |
301 | const int size = start + nr; | 301 | const unsigned int size = start + len; |
302 | int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); | 302 | int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); |
303 | unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start); | 303 | unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start); |
304 | 304 | ||
305 | while (nr - bits_to_clear >= 0) { | 305 | while (len - bits_to_clear >= 0) { |
306 | *p &= ~mask_to_clear; | 306 | *p &= ~mask_to_clear; |
307 | nr -= bits_to_clear; | 307 | len -= bits_to_clear; |
308 | bits_to_clear = BITS_PER_LONG; | 308 | bits_to_clear = BITS_PER_LONG; |
309 | mask_to_clear = ~0UL; | 309 | mask_to_clear = ~0UL; |
310 | p++; | 310 | p++; |
311 | } | 311 | } |
312 | if (nr) { | 312 | if (len) { |
313 | mask_to_clear &= BITMAP_LAST_WORD_MASK(size); | 313 | mask_to_clear &= BITMAP_LAST_WORD_MASK(size); |
314 | *p &= ~mask_to_clear; | 314 | *p &= ~mask_to_clear; |
315 | } | 315 | } |