mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 21:53:44 +00:00
m68k/mm: Make pfn accessors static inlines
Making virt_to_pfn() a static inline taking a strongly typed (const void *) makes the contract of a passing a pointer of that type to the function explicit and exposes any misuse of the macro virt_to_pfn() acting polymorphic and accepting many types such as (void *), (unitptr_t) or (unsigned long) as arguments without warnings. For symmetry, do the same with pfn_to_virt(). Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
c94b1a012f
commit
ef7d0f5d03
@ -121,8 +121,15 @@ static inline void *__va(unsigned long x)
|
||||
* TODO: implement (fast) pfn<->pgdat_idx conversion functions, this makes lots
|
||||
* of the shifts unnecessary.
|
||||
*/
|
||||
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
|
||||
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
|
||||
static inline unsigned long virt_to_pfn(const void *kaddr)
|
||||
{
|
||||
return __pa(kaddr) >> PAGE_SHIFT;
|
||||
}
|
||||
|
||||
static inline void *pfn_to_virt(unsigned long pfn)
|
||||
{
|
||||
return __va(pfn << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
extern int m68k_virt_to_node_shift;
|
||||
|
||||
|
@ -19,8 +19,15 @@ extern unsigned long memory_end;
|
||||
#define __pa(vaddr) ((unsigned long)(vaddr))
|
||||
#define __va(paddr) ((void *)((unsigned long)(paddr)))
|
||||
|
||||
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
|
||||
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
|
||||
static inline unsigned long virt_to_pfn(const void *kaddr)
|
||||
{
|
||||
return __pa(kaddr) >> PAGE_SHIFT;
|
||||
}
|
||||
|
||||
static inline void *pfn_to_virt(unsigned long pfn)
|
||||
{
|
||||
return __va(pfn << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
|
||||
#define page_to_virt(page) __va(((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET))
|
||||
|
Loading…
Reference in New Issue
Block a user