Skip to content

Commit

Permalink
s390/mm: add missing virt_to_pfn() etc. helper functions
Browse files Browse the repository at this point in the history
Add all the missing little helper functions like virt_to_pfn(),
phys_to_page(), etc.  While we had a couple of these helper functions
like e.g. page_to_phys() the other functions were missing, which is
quite annoying if one is looking for exactly such a function.

Therefore finally add all those little helper functions.

Signed-off-by: Heiko Carstens <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
  • Loading branch information
heicarst authored and Martin Schwidefsky committed Aug 9, 2017
1 parent ac34bbc commit 16f4864
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions arch/s390/include/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,26 @@ static inline int devmem_is_allowed(unsigned long pfn)

#endif /* !__ASSEMBLY__ */

#define __PAGE_OFFSET 0x0UL
#define PAGE_OFFSET 0x0UL
#define __pa(x) (unsigned long)(x)
#define __va(x) (void *)(unsigned long)(x)
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
#define __PAGE_OFFSET 0x0UL
#define PAGE_OFFSET 0x0UL

#define __pa(x) ((unsigned long)(x))
#define __va(x) ((void *)(unsigned long)(x))

#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)

#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
#define page_to_virt(page) pfn_to_virt(page_to_pfn(page))

#define phys_to_pfn(kaddr) ((kaddr) >> PAGE_SHIFT)
#define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)

#define phys_to_page(kaddr) pfn_to_page(phys_to_pfn(kaddr))
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)

#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)

#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)

Expand Down

0 comments on commit 16f4864

Please sign in to comment.