Skip to contentSkip to conversation

powerpc/mm: use memblock_is_memory

PATCH In review Alexander Kuleshov 2 participants 2 messages Oct 9, 2015 – Oct 12, 2015 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mm: use memblock_is_memory

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.

---
 arch/powerpc/mm/mem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/mm/mem.c +2 -4
index 22d94c3..85b462b 100644
@@ -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

#1 lore raw
Quoted 3 lines · Alexander Kuleshov

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 6 lines
arch/powerpc/mm/mem.c +0 -0
index 22d94c3..85b462b 100644
@@ -82,11 +82,9 @@ int page_is_ram(unsigned long pfn)
 	return pfn < max_pfn;

arch/powerpc/mm/mem.c int page_is_ram(unsigned long pfn) · line 88

Quoted 10 lines
arch/powerpc/mm/mem.c +2 -4
 #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