From cc2753448d9f2adf48295f935a7eee36023ba8d3 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Mon, 14 May 2012 18:55:50 -0700 Subject: [PATCH] memblock: Add memblock_overlaps_memory() Add a new function, memblock_overlaps_memory(), to check if a region overlaps with a memory bank. This will be used by peripheral loader code to detect when kernel memory would be overwritten. Change-Id: I851f8f416a0f36e85c0e19536b5209f7d4bd431c Signed-off-by: Stephen Boyd (cherry picked from commit 1aa4e5a974b3087d29510802810170c071df8546) Conflicts: include/linux/memblock.h --- include/linux/memblock.h | 1 + mm/memblock.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index f388203db7e8..2aaa6a7f1f63 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -161,6 +161,7 @@ phys_addr_t memblock_end_of_DRAM(void); void memblock_enforce_memory_limit(phys_addr_t memory_limit); int memblock_is_memory(phys_addr_t addr); int memblock_is_region_memory(phys_addr_t base, phys_addr_t size); +int memblock_overlaps_memory(phys_addr_t base, phys_addr_t size); int memblock_is_reserved(phys_addr_t addr); int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); diff --git a/mm/memblock.c b/mm/memblock.c index c5fad932fa51..a794c5446a29 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -936,6 +936,12 @@ int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size memblock.memory.regions[idx].size) >= end; } +int __init_memblock memblock_overlaps_memory(phys_addr_t base, phys_addr_t size) +{ + memblock_cap_size(base, &size); + return memblock_overlaps_region(&memblock.memory, base, size) >= 0; +} + /** * memblock_is_region_reserved - check if a region intersects reserved memory * @base: base of region to check