From: Andrew Morton ifdef reduction. Cc: David Howells Signed-off-by: Andrew Morton --- drivers/char/mem.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) diff -puN fs/char_dev.c~nommu-set-bdi-capabilities-for-dev-mem-and-dev-kmem-tidy fs/char_dev.c diff -puN drivers/char/mem.c~nommu-set-bdi-capabilities-for-dev-mem-and-dev-kmem-tidy drivers/char/mem.c --- a/drivers/char/mem.c~nommu-set-bdi-capabilities-for-dev-mem-and-dev-kmem-tidy +++ a/drivers/char/mem.c @@ -249,6 +249,19 @@ static unsigned long get_unmapped_area_m return (unsigned long) -EINVAL; return pgoff; } + +/* can't do an in-place private mapping if there's no MMU */ +static inline int private_mapping_ok(struct vm_area_struct *vma) +{ + return vma->vm_flags & VM_MAYSHARE; +} +#else +#define get_unmapped_area_mem NULL + +static inline int private_mapping_ok(struct vm_area_struct *vma) +{ + return 1; +} #endif static int mmap_mem(struct file * file, struct vm_area_struct * vma) @@ -258,11 +271,8 @@ static int mmap_mem(struct file * file, if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size)) return -EINVAL; -#ifndef CONFIG_MMU - /* can't do an in-place private mapping if there's no MMU */ - if (!(vma->vm_flags & VM_MAYSHARE)) + if (!private_mapping_ok(vma)) return -ENOSYS; -#endif vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff, size, @@ -801,9 +811,7 @@ static const struct file_operations mem_ .write = write_mem, .mmap = mmap_mem, .open = open_mem, -#ifndef CONFIG_MMU .get_unmapped_area = get_unmapped_area_mem, -#endif }; static const struct file_operations kmem_fops = { @@ -812,9 +820,7 @@ static const struct file_operations kmem .write = write_kmem, .mmap = mmap_kmem, .open = open_kmem, -#ifndef CONFIG_MMU .get_unmapped_area = get_unmapped_area_mem, -#endif }; static const struct file_operations null_fops = { _