mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-23 06:38:04 +07:00
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>
This commit is contained in:
parent
cd621274b0
commit
4991e7251e
@ -28,9 +28,10 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
|
|||||||
struct inode *inode = file->f_mapping->host;
|
struct inode *inode = file->f_mapping->host;
|
||||||
struct mtd_info *mtd = inode->i_sb->s_mtd;
|
struct mtd_info *mtd = inode->i_sb->s_mtd;
|
||||||
unsigned long isize, offset, maxpages, lpages;
|
unsigned long isize, offset, maxpages, lpages;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!mtd)
|
if (!mtd)
|
||||||
goto cant_map_directly;
|
return (unsigned long) -ENOSYS;
|
||||||
|
|
||||||
/* the mapping mustn't extend beyond the EOF */
|
/* the mapping mustn't extend beyond the EOF */
|
||||||
lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
||||||
@ -41,8 +42,6 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
|
|||||||
if ((pgoff >= maxpages) || (maxpages - pgoff < lpages))
|
if ((pgoff >= maxpages) || (maxpages - pgoff < lpages))
|
||||||
return (unsigned long) -EINVAL;
|
return (unsigned long) -EINVAL;
|
||||||
|
|
||||||
/* we need to call down to the MTD layer to do the actual mapping */
|
|
||||||
if (mtd->get_unmapped_area) {
|
|
||||||
if (addr != 0)
|
if (addr != 0)
|
||||||
return (unsigned long) -EINVAL;
|
return (unsigned long) -EINVAL;
|
||||||
|
|
||||||
@ -53,11 +52,10 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
|
|||||||
if (offset > mtd->size - len)
|
if (offset > mtd->size - len)
|
||||||
return (unsigned long) -EINVAL;
|
return (unsigned long) -EINVAL;
|
||||||
|
|
||||||
return mtd_get_unmapped_area(mtd, len, offset, flags);
|
ret = mtd_get_unmapped_area(mtd, len, offset, flags);
|
||||||
}
|
if (ret == -EOPNOTSUPP)
|
||||||
|
ret = -ENOSYS;
|
||||||
cant_map_directly:
|
return (unsigned long) ret;
|
||||||
return (unsigned long) -ENOSYS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user