Skip to content

Commit 232ba16

Browse files
Linus Walleijstffrdhrn
authored andcommitted
openrisc: Make pfn accessors statics 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(). Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Stafford Horne <shorne@gmail.com>
1 parent 52a93d3 commit 232ba16

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • arch/openrisc/include/asm

arch/openrisc/include/asm/page.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,15 @@ typedef struct page *pgtable_t;
7272
#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
7373
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
7474

75-
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
76-
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
75+
static inline unsigned long virt_to_pfn(const void *kaddr)
76+
{
77+
return __pa(kaddr) >> PAGE_SHIFT;
78+
}
79+
80+
static inline void * pfn_to_virt(unsigned long pfn)
81+
{
82+
return (void *)((unsigned long)__va(pfn) << PAGE_SHIFT);
83+
}
7784

7885
#define virt_to_page(addr) \
7986
(mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))

0 commit comments

Comments
 (0)