mtd: introduce mtd_has_oob helper
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Mon Jan 9 13:59:15 EST 2012
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=fc002e3c320602d0e206f607aca0460540d7637a
Commit: fc002e3c320602d0e206f607aca0460540d7637a
Parent: 33c87b4a2c820316314542ce3f60b8a8c6a96928
Author: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
AuthorDate: Wed Dec 28 18:35:07 2011 +0200
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Jan 9 18:26:08 2012 +0000
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 at linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/mtdchar.c | 2 +-
drivers/mtd/sm_ftl.c | 4 ++--
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 83b0c82..c501eec 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)
break;
case MTD_FILE_MODE_RAW:
- if (!mtd->read_oob || !mtd->write_oob)
+ if (!mtd_has_oob(mtd))
return -EOPNOTSUPP;
mfi->mode = arg;
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index 4ec2af7..072ed59 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)
if (!ftl->smallpagenand && mtd->oobsize < SM_OOB_SIZE)
return -ENODEV;
- /* We use these functions for IO */
- if (!mtd->read_oob || !mtd->write_oob)
+ /* We use OOB */
+ if (!mtd_has_oob(mtd))
return -ENODEV;
/* Find geometry information */
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index f0dd5a30..4787015 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)
return do_div(sz, mtd->writesize);
}
+static inline int mtd_has_oob(const struct mtd_info *mtd)
+{
+ return mtd->read_oob && mtd->write_oob;
+}
+
/* Kernel-side ioctl definitions */
struct mtd_partition;
More information about the linux-mtd-cvs
mailing list