提交 9eaa903c 编写于 作者: N Nicolas Pitre 提交者: Richard Weinberger

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: NNicolas Pitre <nico@linaro.org>
Reviewed-by: NRichard Weinberger <richard@nod.at>
Acked-by: NBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: NRichard Weinberger <richard@nod.at>
上级 55100cfa
...@@ -1022,11 +1022,18 @@ EXPORT_SYMBOL_GPL(mtd_unpoint); ...@@ -1022,11 +1022,18 @@ EXPORT_SYMBOL_GPL(mtd_unpoint);
unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len, unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
unsigned long offset, unsigned long flags) unsigned long offset, unsigned long flags)
{ {
if (!mtd->_get_unmapped_area) size_t retlen;
return -EOPNOTSUPP; void *virt;
if (offset >= mtd->size || len > mtd->size - offset) int ret;
return -EINVAL;
return mtd->_get_unmapped_area(mtd, len, offset, flags); 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); EXPORT_SYMBOL_GPL(mtd_get_unmapped_area);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册