From: Sonic Zhang Date: Wed, 5 Oct 2011 00:43:02 +0000 (+1100) Subject: include/asm-generic/page.h: calculate virt_to_page and page_to_virt via predefined... X-Git-Tag: next-20111013~1^2~175 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=50ec0ea743c565506468a5654036f4bb1cd2d554;p=karo-tx-linux.git include/asm-generic/page.h: calculate virt_to_page and page_to_virt via predefined macro On NOMMU architectures, if physical memory doesn't start from 0, ARCH_PFN_OFFSET is defined to generate page index in mem_map array. Because virtual address is equal to physical address, PAGE_OFFSET is always 0. virt_to_page and page_to_virt should not index page by PAGE_OFFSET directly. Signed-off-by: Sonic Zhang Cc: Greg Ungerer Cc: Geert Uytterhoeven Cc: David Howells Signed-off-by: Andrew Morton --- diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h index f376db24c4a6..37d1fe28960a 100644 --- a/include/asm-generic/page.h +++ b/include/asm-generic/page.h @@ -83,8 +83,8 @@ extern unsigned long memory_end; #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) -#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) -#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) +#define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr)) +#define page_to_virt(page) pfn_to_virt(page_to_pfn(page)) #ifndef page_to_phys #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)