diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-28 11:35:07 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:08 -0500 |
commit | fc002e3c320602d0e206f607aca0460540d7637a (patch) | |
tree | 59a0a24c3f842da192febfcc5de263a339f1dcc5 | |
parent | 33c87b4a2c820316314542ce3f60b8a8c6a96928 (diff) |
mtd: introduce mtd_has_oob helper
We are working in the direction of making sure that MTD clients to not
use 'mtd->func' pointers directly. In some places we want to know if
OOB operations are supported by an MTD device. Introduce 'mtd_has_oob()'
helper for these purposes.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/mtdchar.c | 2 | ||||
-rw-r--r-- | drivers/mtd/sm_ftl.c | 4 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 5 |
3 files changed, 8 insertions, 3 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 83b0c82e9c94..c501eec17b38 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -1004,7 +1004,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
1004 | break; | 1004 | break; |
1005 | 1005 | ||
1006 | case MTD_FILE_MODE_RAW: | 1006 | case MTD_FILE_MODE_RAW: |
1007 | if (!mtd->read_oob || !mtd->write_oob) | 1007 | if (!mtd_has_oob(mtd)) |
1008 | return -EOPNOTSUPP; | 1008 | return -EOPNOTSUPP; |
1009 | mfi->mode = arg; | 1009 | mfi->mode = arg; |
1010 | 1010 | ||
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index 4ec2af7fb845..072ed5970e2f 100644 --- a/drivers/mtd/sm_ftl.c +++ b/drivers/mtd/sm_ftl.c | |||
@@ -645,8 +645,8 @@ int sm_get_media_info(struct sm_ftl *ftl, struct mtd_info *mtd) | |||
645 | if (!ftl->smallpagenand && mtd->oobsize < SM_OOB_SIZE) | 645 | if (!ftl->smallpagenand && mtd->oobsize < SM_OOB_SIZE) |
646 | return -ENODEV; | 646 | return -ENODEV; |
647 | 647 | ||
648 | /* We use these functions for IO */ | 648 | /* We use OOB */ |
649 | if (!mtd->read_oob || !mtd->write_oob) | 649 | if (!mtd_has_oob(mtd)) |
650 | return -ENODEV; | 650 | return -ENODEV; |
651 | 651 | ||
652 | /* Find geometry information */ | 652 | /* Find geometry information */ |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index f0dd5a305b89..478701566ba7 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -454,6 +454,11 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) | |||
454 | return do_div(sz, mtd->writesize); | 454 | return do_div(sz, mtd->writesize); |
455 | } | 455 | } |
456 | 456 | ||
457 | static inline int mtd_has_oob(const struct mtd_info *mtd) | ||
458 | { | ||
459 | return mtd->read_oob && mtd->write_oob; | ||
460 | } | ||
461 | |||
457 | /* Kernel-side ioctl definitions */ | 462 | /* Kernel-side ioctl definitions */ |
458 | 463 | ||
459 | struct mtd_partition; | 464 | struct mtd_partition; |