/* NOMMU mmap support for RomFS on MTD devices * * Copyright © 2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include #include #include "internal.h" /* * try to determine where a shared mapping can be made * - only supported for NOMMU at the moment (MMU can't doesn't copy private * mappings) * - attempts to map through to the underlying MTD device */ static unsigned long romfs_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { struct inode *inode = file->f_mapping->host; struct mtd_info *mtd = inode->i_sb->s_mtd; unsigned long isize, offset, maxpages, lpages; int ret; if (!mtd) return (unsigned long) -ENOSYS; /* the mapping mustn't extend beyond the EOF */ lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; isize = i_size_read(inode); offset = pgoff << PAGE_SHIFT; maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT; if ((pgoff >= maxpages) || (maxpages - pgoff < lpages)) return (unsigned long) -EINVAL; if (addr != 0) return (unsigned long) -EINVAL; if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) return (unsigned long) -EINVAL; offset += ROMFS_I(inode)->i_dataoffset; if (offset >= mtd->size) return (unsigned long) -EINVAL; /* the mapping mustn't extend beyond the EOF */ if ((offset + len) > mtd->size) len = mtd->size - offset; ret = mtd_get_unmapped_area(mtd, len, offset, flags); if (ret == -EOPNOTSUPP) ret = -ENOSYS; return (unsigned long) ret; } /* * permit a R/O mapping to be made directly through onto an MTD device if * possible */ static int romfs_mmap(struct file *file, struct vm_area_struct *vma) { return vma->vm_flags & (VM_SHARED | VM_MAYSHARE) ? 0 : -ENOSYS; } static unsigned romfs_mmap_capabilities(struct file *file) { struct mtd_info *mtd = file_inode(file)->i_sb->s_mtd; if (!mtd) return NOMMU_MAP_COPY; return mtd_mmap_capabilities(mtd); } const struct file_operations romfs_ro_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, .splice_read = generic_file_splice_read, .mmap = romfs_mmap, .get_unmapped_area = romfs_get_unmapped_area, .mmap_capabilities = romfs_mmap_capabilities, }; alue=''/>
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-18 11:13:41 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-18 11:13:41 -0800
commitca92e6c7e6329029d7188487a5c32e86ef471977 (patch)
tree704fb5c2ca533cdb569826522eed0dbbcf31f316 /sound/soc/atmel
parent0b75f821ec8be459dd4dec77be39595d989d77ac (diff)
parent4205e4786d0b9fc3b4fec7b1910cf645a0468307 (diff)
Merge branch 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull SMP hotplug update from Thomas Gleixner: "This contains a trivial typo fix and an extension to the core code for dynamically allocating states in the prepare stage. The extension is necessary right now because we need a proper way to unbreak LTTNG, which iscurrently non functional due to the removal of the notifiers. Surely it's out of tree, but it's widely used by distros. The simple solution would have been to reserve a state for LTTNG, but I'm not fond about unused crap in the kernel and the dynamic range, which we admittedly should have done right away, allows us to remove quite some of the hardcoded states, i.e. those which have no ordering requirements. So doing the right thing now is better than having an smaller intermediate solution which needs to be reworked anyway" * 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: cpu/hotplug: Provide dynamic range for prepare stage perf/x86/amd/ibs: Fix typo after cleanup state names in cpu/hotplug
Diffstat (limited to 'sound/soc/atmel')