Skip to content

Commit

Permalink
mtd: nand: add a helper to detect the nand type
Browse files Browse the repository at this point in the history
This helper detects that whether the mtd's type is nand type.

Now, it's clear that the MTD_NANDFLASH stands for SLC nand only.
So use the mtd_type_is_nand() to replace the old check method
to do the nand type (include the SLC and MLC) check.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  • Loading branch information
Huang Shijie authored and computersforpeace committed Oct 27, 2013
1 parent fda5b0e commit 818b973
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion drivers/mtd/inftlcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
struct INFTLrecord *inftl;
unsigned long temp;

if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX)
if (!mtd_type_is_nand(mtd) || mtd->size > UINT_MAX)
return;
/* OK, this is moderately ugly. But probably safe. Alternatives? */
if (memcmp(mtd->name, "DiskOnChip", 10))
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nftlcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
struct NFTLrecord *nftl;
unsigned long temp;

if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX)
if (!mtd_type_is_nand(mtd) || mtd->size > UINT_MAX)
return;
/* OK, this is moderately ugly. But probably safe. Alternatives? */
if (memcmp(mtd->name, "DiskOnChip", 10))
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/ssfdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
int cis_sector;

/* Check for small page NAND flash */
if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE ||
if (!mtd_type_is_nand(mtd) || mtd->oobsize != OOB_SIZE ||
mtd->size > UINT_MAX)
return;

Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/tests/nandbiterrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static int __init mtd_nandbiterrs_init(void)
goto exit_mtddev;
}

if (mtd->type != MTD_NANDFLASH) {
if (!mtd_type_is_nand(mtd)) {
pr_info("this test requires NAND flash\n");
err = -ENODEV;
goto exit_nand;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/tests/oobtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static int __init mtd_oobtest_init(void)
return err;
}

if (mtd->type != MTD_NANDFLASH) {
if (!mtd_type_is_nand(mtd)) {
pr_info("this test requires NAND flash\n");
goto out;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/tests/pagetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static int __init mtd_pagetest_init(void)
return err;
}

if (mtd->type != MTD_NANDFLASH) {
if (!mtd_type_is_nand(mtd)) {
pr_info("this test requires NAND flash\n");
goto out;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/tests/subpagetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static int __init mtd_subpagetest_init(void)
return err;
}

if (mtd->type != MTD_NANDFLASH) {
if (!mtd_type_is_nand(mtd)) {
pr_info("this test requires NAND flash\n");
goto out;
}
Expand Down
5 changes: 5 additions & 0 deletions include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ static inline int mtd_has_oob(const struct mtd_info *mtd)
return mtd->_read_oob && mtd->_write_oob;
}

static inline int mtd_type_is_nand(const struct mtd_info *mtd)
{
return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
}

static inline int mtd_can_have_bb(const struct mtd_info *mtd)
{
return !!mtd->_block_isbad;
Expand Down

0 comments on commit 818b973

Please sign in to comment.