aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorChen Gang <gang.chen.5i5j@gmail.com>2014-04-14 21:21:30 -0400
committerGuan Xuetao <gxt@mprc.pku.edu.cn>2014-06-19 20:22:40 -0400
commit8a016596a56282f1414cf90e575040cffdabe68e (patch)
tree7c64c581f6728435c5220bdc940ac3628f15715b /arch
parentaaad61838242469b0f9724a6057ea74ab4e87369 (diff)
arch:unicore32:mm: add devmem_is_allowed() to support STRICT_DEVMEM
unicore32 supports STRICT_DEVMEM, so it needs devmem_is_allowed(), like some of other architectures have done (e.g. arm, powerpc, x86 ...). The related error with allmodconfig: CC drivers/char/mem.o drivers/char/mem.c: In function ‘range_is_allowed’: drivers/char/mem.c:69: error: implicit declaration of function ‘devmem_is_allowed’ make[2]: *** [drivers/char/mem.o] Error 1 make[1]: *** [drivers/char] Error 2 make: *** [drivers] Error 2 Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Acked-by: Xuetao Guan <gxt@mprc.pku.edu.cn> Signed-off-by: Xuetao Guan <gxt@mprc.pku.edu.cn>
Diffstat (limited to 'arch')
-rw-r--r--arch/unicore32/include/asm/io.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/unicore32/include/asm/io.h b/arch/unicore32/include/asm/io.h
index d6920301465a..cb1d8fd2b16b 100644
--- a/arch/unicore32/include/asm/io.h
+++ b/arch/unicore32/include/asm/io.h
@@ -48,5 +48,28 @@ extern void __uc32_iounmap(volatile void __iomem *addr);
48#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) 48#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
49#define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1) 49#define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1)
50 50
51#ifdef CONFIG_STRICT_DEVMEM
52
53#include <linux/ioport.h>
54#include <linux/mm.h>
55
56/*
57 * devmem_is_allowed() checks to see if /dev/mem access to a certain
58 * address is valid. The argument is a physical page number.
59 * We mimic x86 here by disallowing access to system RAM as well as
60 * device-exclusive MMIO regions. This effectively disable read()/write()
61 * on /dev/mem.
62 */
63static inline int devmem_is_allowed(unsigned long pfn)
64{
65 if (iomem_is_exclusive(pfn << PAGE_SHIFT))
66 return 0;
67 if (!page_is_ram(pfn))
68 return 1;
69 return 0;
70}
71
72#endif /* CONFIG_STRICT_DEVMEM */
73
51#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
52#endif /* __UNICORE_IO_H__ */ 75#endif /* __UNICORE_IO_H__ */