Skip to content

Commit

Permalink
nios2: Convert pfn_valid to static inline
Browse files Browse the repository at this point in the history
When compiling with 'W=1' warnings such as the following occur all over
the place:

  ./include/linux/pfn.h:21:22: warning: comparison of unsigned expression
    >= 0 is always true [-Wtype-limits]

which is due to ARCH_PFN_OFFSET being 0 by default
(if CONFIG_NIOS2_MEM_BASE is not changed in the Kconfig). Fix these
warnings by making pfn_valid a static inline function.

Signed-off-by: Tobias Klauser <[email protected]>
Signed-off-by: Ley Foon Tan <[email protected]>
  • Loading branch information
tklauser authored and Ley Foon Tan committed Dec 13, 2016
1 parent 3c98fd2 commit 863cf8d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions arch/nios2/include/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@ extern struct page *mem_map;
((void *)(((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)

# define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
# define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && \
(pfn) < max_mapnr)

static inline bool pfn_valid(unsigned long pfn)
{
/* avoid <linux/mm.h> include hell */
extern unsigned long max_mapnr;
unsigned long pfn_offset = ARCH_PFN_OFFSET;

return pfn >= pfn_offset && pfn < max_mapnr;
}

# define virt_to_page(vaddr) pfn_to_page(PFN_DOWN(virt_to_phys(vaddr)))
# define virt_addr_valid(vaddr) pfn_valid(PFN_DOWN(virt_to_phys(vaddr)))
Expand Down

0 comments on commit 863cf8d

Please sign in to comment.