diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-28 10:50:34 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:14 -0500 |
commit | dac2639f9833e858139d7e07f6ee45fb2191a9f2 (patch) | |
tree | 8927b0959d8415e419f321a8b43974ed8834b680 /drivers/mtd | |
parent | 016c1291ce70a22f15f666441a4fd2f0b450375b (diff) |
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdchar.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 55f0961103a7..287ff0d35848 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -452,13 +452,8 @@ static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, | |||
452 | if (length > 4096) | 452 | if (length > 4096) |
453 | return -EINVAL; | 453 | return -EINVAL; |
454 | 454 | ||
455 | if (!mtd->read_oob) | 455 | if (!access_ok(VERIFY_WRITE, ptr, length)) |
456 | ret = -EOPNOTSUPP; | 456 | return -EFAULT; |
457 | else | ||
458 | ret = access_ok(VERIFY_WRITE, ptr, | ||
459 | length) ? 0 : -EFAULT; | ||
460 | if (ret) | ||
461 | return ret; | ||
462 | 457 | ||
463 | ops.ooblen = length; | 458 | ops.ooblen = length; |
464 | ops.ooboffs = start & (mtd->writesize - 1); | 459 | ops.ooboffs = start & (mtd->writesize - 1); |