Skip to content

Commit fc002e3

Browse files
dedekindDavid Woodhouse
authored andcommitted
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>
1 parent 33c87b4 commit fc002e3

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎drivers/mtd/mtdchar.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
10041004
break;
10051005

10061006
case MTD_FILE_MODE_RAW:
1007-
if (!mtd->read_oob || !mtd->write_oob)
1007+
if (!mtd_has_oob(mtd))
10081008
return -EOPNOTSUPP;
10091009
mfi->mode = arg;
10101010

‎drivers/mtd/sm_ftl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,8 @@ int sm_get_media_info(struct sm_ftl *ftl, struct mtd_info *mtd)
645645
if (!ftl->smallpagenand && mtd->oobsize < SM_OOB_SIZE)
646646
return -ENODEV;
647647

648-
/* We use these functions for IO */
649-
if (!mtd->read_oob || !mtd->write_oob)
648+
/* We use OOB */
649+
if (!mtd_has_oob(mtd))
650650
return -ENODEV;
651651

652652
/* Find geometry information */

‎include/linux/mtd/mtd.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
454454
return do_div(sz, mtd->writesize);
455455
}
456456

457+
static inline int mtd_has_oob(const struct mtd_info *mtd)
458+
{
459+
return mtd->read_oob && mtd->write_oob;
460+
}
461+
457462
/* Kernel-side ioctl definitions */
458463

459464
struct mtd_partition;

0 commit comments

Comments
 (0)