From: Andrew Morton Date: Thu, 9 May 2013 23:57:25 +0000 (+1000) Subject: lib-bitmapc-speed-up-bitmap_find_free_region-fix X-Git-Tag: next-20130521~1^2~116 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9ee746aa83bd7f204e571655afe1a0cadf7ef451;p=karo-tx-linux.git lib-bitmapc-speed-up-bitmap_find_free_region-fix reduce scope of locals, remove barely comprehensible comment Cc: Chanho Min Cc: Jiri Kosina Cc: Joe Perches Cc: Nadia Yvette Chambers Cc: anish singh Signed-off-by: Andrew Morton --- diff --git a/lib/bitmap.c b/lib/bitmap.c index 95e8efc18f68..ea190b7047c3 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -1114,13 +1114,15 @@ done: */ int bitmap_find_free_region(unsigned long *bitmap, int bits, int order) { - int pos, end, nbit, i; /* scans bitmap by regions of size order */ int nlongs = BITS_TO_LONGS(bits); + int i; for (i = 0; i < nlongs; i++) if (bitmap[i] != ~0UL) { - pos = i * BITS_PER_LONG; - nbit = min(bits, pos + BITS_PER_LONG); + int pos = i * BITS_PER_LONG; + int nbit = min(bits, pos + BITS_PER_LONG); + int end; + for (; (end = pos + (1 << order)) <= nbit; pos = end) { if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))