diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-28 10:08:03 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:12 -0500 |
commit | 4991e7251ed951a5f33faf25912e9db416306309 (patch) | |
tree | 77454b88465118f8cf1127049cbf96c47da2c415 /fs | |
parent | cd621274b0ec747db8dedbf857624c067f481976 (diff) |
romfs: do not use mtd->get_unmapped_area directly
Remove direct usage of mtd->get_unmapped_area. Instead, just call
'mtd_get_unmapped_area()' which will return -EOPNOTSUPP if the function
is not implemented, and then test for this code.
We also translate -EOPNOTSUPP to -ENOSYS because this return code is
probably part of the kernel ABI which we do not want to break.
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/romfs/mmap-nommu.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c index d5168e8e7dcb..e1a7779dd3cb 100644 --- a/fs/romfs/mmap-nommu.c +++ b/fs/romfs/mmap-nommu.c | |||
@@ -28,9 +28,10 @@ static unsigned long romfs_get_unmapped_area(struct file *file, | |||
28 | struct inode *inode = file->f_mapping->host; | 28 | struct inode *inode = file->f_mapping->host; |
29 | struct mtd_info *mtd = inode->i_sb->s_mtd; | 29 | struct mtd_info *mtd = inode->i_sb->s_mtd; |
30 | unsigned long isize, offset, maxpages, lpages; | 30 | unsigned long isize, offset, maxpages, lpages; |
31 | int ret; | ||
31 | 32 | ||
32 | if (!mtd) | 33 | if (!mtd) |
33 | goto cant_map_directly; | 34 | return (unsigned long) -ENOSYS; |
34 | 35 | ||
35 | /* the mapping mustn't extend beyond the EOF */ | 36 | /* the mapping mustn't extend beyond the EOF */ |
36 | lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; | 37 | lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; |
@@ -41,23 +42,20 @@ static unsigned long romfs_get_unmapped_area(struct file *file, | |||
41 | if ((pgoff >= maxpages) || (maxpages - pgoff < lpages)) | 42 | if ((pgoff >= maxpages) || (maxpages - pgoff < lpages)) |
42 | return (unsigned long) -EINVAL; | 43 | return (unsigned long) -EINVAL; |
43 | 44 | ||
44 | /* we need to call down to the MTD layer to do the actual mapping */ | 45 | if (addr != 0) |
45 | if (mtd->get_unmapped_area) { | 46 | return (unsigned long) -EINVAL; |
46 | if (addr != 0) | ||
47 | return (unsigned long) -EINVAL; | ||
48 | |||
49 | if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) | ||
50 | return (unsigned long) -EINVAL; | ||
51 | 47 | ||
52 | offset += ROMFS_I(inode)->i_dataoffset; | 48 | if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) |
53 | if (offset > mtd->size - len) | 49 | return (unsigned long) -EINVAL; |
54 | return (unsigned long) -EINVAL; | ||
55 | 50 | ||
56 | return mtd_get_unmapped_area(mtd, len, offset, flags); | 51 | offset += ROMFS_I(inode)->i_dataoffset; |
57 | } | 52 | if (offset > mtd->size - len) |
53 | return (unsigned long) -EINVAL; | ||
58 | 54 | ||
59 | cant_map_directly: | 55 | ret = mtd_get_unmapped_area(mtd, len, offset, flags); |
60 | return (unsigned long) -ENOSYS; | 56 | if (ret == -EOPNOTSUPP) |
57 | ret = -ENOSYS; | ||
58 | return (unsigned long) ret; | ||
61 | } | 59 | } |
62 | 60 | ||
63 | /* | 61 | /* |