From: Wei Yang Date: Wed, 22 Feb 2017 23:45:04 +0000 (-0800) Subject: mm/memblock.c: trivial code refine in memblock_is_region_memory() X-Git-Tag: v4.14-rc1~1445^2~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef415ef41153b747031e8ad965cb3df4f22ff72e;p=platform%2Fkernel%2Flinux-rpi3.git mm/memblock.c: trivial code refine in memblock_is_region_memory() memblock_is_region_memory() invoke memblock_search() to see whether the base address is in the memory region. If it fails, idx would be -1. Then, it returns 0. If the memblock_search() returns a valid index, it means the base address is guaranteed to be in the range memblock.memory.regions[idx]. Because of this, it is not necessary to check the base again. This patch removes the check on "base". Link: http://lkml.kernel.org/r/1482363033-24754-2-git-send-email-richard.weiyang@gmail.com Signed-off-by: Wei Yang Acked-by: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memblock.c b/mm/memblock.c index a476d28..90171d5 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1640,8 +1640,7 @@ int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size if (idx == -1) return 0; - return memblock.memory.regions[idx].base <= base && - (memblock.memory.regions[idx].base + + return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size) >= end; }