aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2014-08-06 19:10:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:26 -0400
commit154f5e38f30f262025c8c2e825376f6eb51e8bcb (patch)
tree2b9850d703dfe9d0a7dca3748f7f4781f9a6c3b2 /lib
parentfb5ac54263ef3fcb5c469a61e0ab6b06e45e2307 (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>
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c10
1 files changed, 5 insertions, 5 deletions
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}
296EXPORT_SYMBOL(bitmap_set); 296EXPORT_SYMBOL(bitmap_set);
297 297
298void bitmap_clear(unsigned long *map, int start, int nr) 298void 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 }