From c3fe57d40d6b8ce975f3d8f4f5e2e4fa1b235d28 Mon Sep 17 00:00:00 2001 From: Chris Humbert Date: Mon, 28 Nov 2005 13:43:54 -0800 Subject: [PATCH] --- yaml --- r: 14718 b: refs/heads/master c: 46596338a10a54550ff03a6f60c28145a080296b h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/lib/genalloc.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 215a2a5586fa..db3bd7dd7cd9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7729ac5efe156129d172784fedeaddb2167a1914 +refs/heads/master: 46596338a10a54550ff03a6f60c28145a080296b diff --git a/trunk/lib/genalloc.c b/trunk/lib/genalloc.c index d6d30d2e7166..9ce0a6a3b85a 100644 --- a/trunk/lib/genalloc.c +++ b/trunk/lib/genalloc.c @@ -95,12 +95,10 @@ unsigned long gen_pool_alloc(struct gen_pool *poolp, int size) if (size > max_chunk_size) return 0; - i = 0; - size = max(size, 1 << ALLOC_MIN_SHIFT); - s = roundup_pow_of_two(size); - - j = i; + i = fls(size - 1); + s = 1 << i; + j = i -= ALLOC_MIN_SHIFT; spin_lock_irqsave(&poolp->lock, flags); while (!h[j].next) { @@ -153,10 +151,10 @@ void gen_pool_free(struct gen_pool *poolp, unsigned long ptr, int size) if (size > max_chunk_size) return; - i = 0; - size = max(size, 1 << ALLOC_MIN_SHIFT); - s = roundup_pow_of_two(size); + i = fls(size - 1); + s = 1 << i; + i -= ALLOC_MIN_SHIFT; a = ptr;