[PATCH] powerpc/mm: use memblock_is_memory

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3949d

2 messages, 2 authors, 2015-10-12 · open the first message on its own page

[PATCH] powerpc/mm: use memblock_is_memory

From: Alexander Kuleshov <hidden>
Date: 2015-10-09 18:32:08

The <linux/memblock.h> provides memblock_is_memory() function that
tries to find a given physical address in the memblock.memory.regions.
Let's use this function instead of direct coding of the same functionality.

Signed-off-by: Alexander Kuleshov <redacted>
---
 arch/powerpc/mm/mem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 22d94c3..85b462b 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -82,11 +82,9 @@ int page_is_ram(unsigned long pfn)
 	return pfn < max_pfn;
 #else
 	unsigned long paddr = (pfn << PAGE_SHIFT);
-	struct memblock_region *reg;

-	for_each_memblock(memory, reg)
-		if (paddr >= reg->base && paddr < (reg->base + reg->size))
-			return 1;
+	if (memblock_is_memory(paddr))
+		return 1;
 	return 0;
 #endif
 }
--
2.6.0

Re: [PATCH] powerpc/mm: use memblock_is_memory

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2015-10-12 09:35:57

On Sat, 2015-10-10 at 00:30 +0600, Alexander Kuleshov wrote:
The <linux/memblock.h> provides memblock_is_memory() function that
tries to find a given physical address in the memblock.memory.regions.
Let's use this function instead of direct coding of the same functionality.
Are you sure it implements exactly the same logic?
quoted hunk
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 22d94c3..85b462b 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -82,11 +82,9 @@ int page_is_ram(unsigned long pfn)
 	return pfn < max_pfn;
 #else
 	unsigned long paddr = (pfn << PAGE_SHIFT);
-	struct memblock_region *reg;

-	for_each_memblock(memory, reg)
-		if (paddr >= reg->base && paddr < (reg->base + reg->size))
-			return 1;
+	if (memblock_is_memory(paddr))
+		return 1;
 	return 0;
Why not just return memblock_is_memory(paddr) ?

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help