summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-03-18 09:57:02 +0100
committerIngo Molnar <mingo@elte.hu>2009-03-18 09:57:02 +0100
commit37ba317c9ed19eb126e40bbf563f2711e191a636 (patch)
treec5865768f341fc0ab41899fe9af9dc5918784cee /lib
parent708dc5125309cd33c5daaad3026cc4ae6ef39c8b (diff)
parentee568b25ee9e160b32d1aef73d8b2ee9c05d34db (diff)
Merge branches 'sched/cleanups' and 'linus' into sched/core
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 1338469ac849..35a1f7ff4149 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -948,15 +948,15 @@ done:
*/
int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
{
- int pos; /* scans bitmap by regions of size order */
+ int pos, end; /* scans bitmap by regions of size order */
- for (pos = 0; pos < bits; pos += (1 << order))
- if (__reg_op(bitmap, pos, order, REG_OP_ISFREE))
- break;
- if (pos == bits)
- return -ENOMEM;
- __reg_op(bitmap, pos, order, REG_OP_ALLOC);
- return pos;
+ for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) {
+ if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+ continue;
+ __reg_op(bitmap, pos, order, REG_OP_ALLOC);
+ return pos;
+ }
+ return -ENOMEM;
}
EXPORT_SYMBOL(bitmap_find_free_region);