Skip to contentSkip to conversation

Simplify pte_offset_map() and pte_offset_map_nested()

PATCH New Franck Bui-Huu 1 participant 1 message Mar 26, 2007 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Simplify pte_offset_map() and pte_offset_map_nested()

From: Franck Bui-Huu <[email protected]>

These 2 macros did unnecessary extra work for getting a pte from a pmd.

With this patch the size of the kernel is slighly reduced (-1036b)

---

Ralf,

This patch does not include any modifications for 64-bits kernel since I can't test them. This patch boot fine on a 32-bits platforms.

Please consider

Franck

 include/asm-mips/pgtable-32.h |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
include/asm-mips/pgtable-32.h +3 -4
index 2fbd47e..a0e76e4 100644
@@ -143,6 +143,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
 #define __pgd_offset(address)	pgd_index(address)
 #define __pud_offset(address)	(((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
 #define __pmd_offset(address)	(((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
+#define __pte_offset(address)	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
 
 /* to find an entry in a kernel page-table-directory */
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
@@ -153,17 +154,15 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
 #define pgd_offset(mm,addr)	((mm)->pgd + pgd_index(addr))
 
 /* Find an entry in the third-level page table.. */
-#define __pte_offset(address)						\
-	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_offset_kernel(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 
 #define pte_offset_map(dir, address)                                    \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_offset_map_nested(dir, address)                             \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_unmap(pte) ((void)(pte))
 #define pte_unmap_nested(pte) ((void)(pte))
 
Signature · 1 line
1.5.1.rc1.g1d848