mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 14:42:37 +02:00
UPSTREAM: mm: add PHYS_PFN, use it in __phys_to_pfn()
(cherry pick from commit 8f235d1a3e)
__phys_to_pfn and __pfn_to_phys are symmetric, PHYS_PFN and PFN_PHYS are
semmetric:
- y = (phys_addr_t)x << PAGE_SHIFT
- y >> PAGE_SHIFT = (phys_add_t)x
- (unsigned long)(y >> PAGE_SHIFT) = x
[akpm@linux-foundation.org: use macro arg name `x']
[arnd@arndb.de: include linux/pfn.h for PHYS_PFN definition]
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bug: 20045882
Bug: 19198045
Change-Id: If968d2246b381b9e5d6446e9d6d9fa45bb718e91
This commit is contained in:
parent
f85bf2f988
commit
d127906192
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __ASM_MEMORY_MODEL_H
|
||||
#define __ASM_MEMORY_MODEL_H
|
||||
|
||||
#include <linux/pfn.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#if defined(CONFIG_FLATMEM)
|
||||
|
|
@ -72,7 +74,7 @@
|
|||
/*
|
||||
* Convert a physical address to a Page Frame Number and back
|
||||
*/
|
||||
#define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT))
|
||||
#define __phys_to_pfn(paddr) PHYS_PFN(paddr)
|
||||
#define __pfn_to_phys(pfn) PFN_PHYS(pfn)
|
||||
|
||||
#define page_to_pfn __page_to_pfn
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@
|
|||
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
|
||||
#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
|
||||
#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
|
||||
#define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT))
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user