linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/mm: use memblock_is_memory
@ 2015-10-09 18:30 Alexander Kuleshov
  2015-10-12  9:35 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kuleshov @ 2015-10-09 18:30 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Paul Mackerras, Michael Ellerman, Anton Blanchard, Scott Wood,
	Dan Williams, linuxppc-dev, linux-kernel, 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.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc/mm: use memblock_is_memory
  2015-10-09 18:30 [PATCH] powerpc/mm: use memblock_is_memory Alexander Kuleshov
@ 2015-10-12  9:35 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2015-10-12  9:35 UTC (permalink / raw)
  To: Alexander Kuleshov
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Anton Blanchard,
	Scott Wood, Dan Williams, linuxppc-dev, linux-kernel

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?

> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-12  9:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 18:30 [PATCH] powerpc/mm: use memblock_is_memory Alexander Kuleshov
2015-10-12  9:35 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).