summaryrefslogtreecommitdiff
path: root/drivers/mtd/mtdcore.c
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2017-10-30 21:48:32 +0300
committerRichard Weinberger <richard@nod.at>2017-11-13 23:39:18 +0300
commit9eaa903c06f9f3129f862ef60ce106e4c3211288 (patch)
tree3baaa770c2f382c2ac97a18ef848a338f537d745 /drivers/mtd/mtdcore.c
parent55100cfa339db9c391f8c4667af02a6f7160125b (diff)
downloadlinux-9eaa903c06f9f3129f862ef60ce106e4c3211288.tar.xz
mtd: implement mtd_get_unmapped_area() using the point method
The mtd->_point method is a superset of mtd->_get_unmapped_area. Especially in the NOR flash case, the point method ensures the flash memory is in array (data) mode and that it will stay that way which is precisely what callers of mtd_get_unmapped_area() would expect. Implement mtd_get_unmapped_area() in terms of mtd->_point now that all drivers that provided a _get_unmapped_area method also have the _point method implemented. Signed-off-by: Nicolas Pitre <nico@linaro.org> Reviewed-by: Richard Weinberger <richard@nod.at> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r--drivers/mtd/mtdcore.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index e7ea842ba3db..ecb0380158f9 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1022,11 +1022,18 @@ EXPORT_SYMBOL_GPL(mtd_unpoint);
unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
unsigned long offset, unsigned long flags)
{
- if (!mtd->_get_unmapped_area)
- return -EOPNOTSUPP;
- if (offset >= mtd->size || len > mtd->size - offset)
- return -EINVAL;
- return mtd->_get_unmapped_area(mtd, len, offset, flags);
+ size_t retlen;
+ void *virt;
+ int ret;
+
+ ret = mtd_point(mtd, offset, len, &retlen, &virt, NULL);
+ if (ret)
+ return ret;
+ if (retlen != len) {
+ mtd_unpoint(mtd, offset, retlen);
+ return -ENOSYS;
+ }
+ return (unsigned long)virt;
}
EXPORT_SYMBOL_GPL(mtd_get_unmapped_area);