mtd: do not use mtd->read_oob directly
Instead of checking whether 'mtd->read_oob' is defined, just call 'mtd_read_oob()' and handle the '-EOPNOTSUPP' error which will be returned if the function is undefined. Additionally, make 'mtd_write_oob()' return '-EOPNOTSUPP' if the function is undefined. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
committed by
David Woodhouse
parent
016c1291ce
commit
dac2639f98
@@ -452,13 +452,8 @@ static int mtdchar_readoob(struct file *file, struct mtd_info *mtd,
|
|||||||
if (length > 4096)
|
if (length > 4096)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!mtd->read_oob)
|
if (!access_ok(VERIFY_WRITE, ptr, length))
|
||||||
ret = -EOPNOTSUPP;
|
return -EFAULT;
|
||||||
else
|
|
||||||
ret = access_ok(VERIFY_WRITE, ptr,
|
|
||||||
length) ? 0 : -EFAULT;
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ops.ooblen = length;
|
ops.ooblen = length;
|
||||||
ops.ooboffs = start & (mtd->writesize - 1);
|
ops.ooboffs = start & (mtd->writesize - 1);
|
||||||
|
@@ -320,6 +320,8 @@ static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from,
|
|||||||
struct mtd_oob_ops *ops)
|
struct mtd_oob_ops *ops)
|
||||||
{
|
{
|
||||||
ops->retlen = ops->oobretlen = 0;
|
ops->retlen = ops->oobretlen = 0;
|
||||||
|
if (!mtd->read_oob)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
return mtd->read_oob(mtd, from, ops);
|
return mtd->read_oob(mtd, from, ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +329,8 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
|
|||||||
struct mtd_oob_ops *ops)
|
struct mtd_oob_ops *ops)
|
||||||
{
|
{
|
||||||
ops->retlen = ops->oobretlen = 0;
|
ops->retlen = ops->oobretlen = 0;
|
||||||
|
if (!mtd->write_oob)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
return mtd->write_oob(mtd, to, ops);
|
return mtd->write_oob(mtd, to, ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user