]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm, vmalloc: use clamp() to simplify code
authorZhang Yanfei <zhangyanfei@cn.fujitsu.com>
Thu, 27 Jun 2013 23:52:11 +0000 (09:52 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 28 Jun 2013 06:37:55 +0000 (16:37 +1000)
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmalloc.c

index bd60bffd9aefc08bee5c66a8c7e0b953a051d498..91a10472a39a833b29ae0be1faeb6c30c72c0160 100644 (file)
@@ -1330,16 +1330,8 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
        struct vm_struct *area;
 
        BUG_ON(in_interrupt());
-       if (flags & VM_IOREMAP) {
-               int bit = fls(size);
-
-               if (bit > IOREMAP_MAX_ORDER)
-                       bit = IOREMAP_MAX_ORDER;
-               else if (bit < PAGE_SHIFT)
-                       bit = PAGE_SHIFT;
-
-               align = 1ul << bit;
-       }
+       if (flags & VM_IOREMAP)
+               align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
 
        size = PAGE_ALIGN(size);
        if (unlikely(!size))