aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2013-09-25 02:58:17 -0400
committerBrian Norris <computersforpeace@gmail.com>2013-10-27 19:27:06 -0400
commit818b97392932ac4cecc36ab839957258367004a9 (patch)
tree9d3d864da226e7068ece1b88ccf8b51b9fb25e4d
parentfda5b0e24dca3d52671e5a6543a285d4e86c55e1 (diff)
mtd: nand: add a helper to detect the nand type
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>
-rw-r--r--drivers/mtd/inftlcore.c2
-rw-r--r--drivers/mtd/nftlcore.c2
-rw-r--r--drivers/mtd/ssfdc.c2
-rw-r--r--drivers/mtd/tests/nandbiterrs.c2
-rw-r--r--drivers/mtd/tests/oobtest.c2
-rw-r--r--drivers/mtd/tests/pagetest.c2
-rw-r--r--drivers/mtd/tests/subpagetest.c2
-rw-r--r--include/linux/mtd/mtd.h5
8 files changed, 12 insertions, 7 deletions
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index 3af351484098..b66b541877f0 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -50,7 +50,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
50 struct INFTLrecord *inftl; 50 struct INFTLrecord *inftl;
51 unsigned long temp; 51 unsigned long temp;
52 52
53 if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) 53 if (!mtd_type_is_nand(mtd) || mtd->size > UINT_MAX)
54 return; 54 return;
55 /* OK, this is moderately ugly. But probably safe. Alternatives? */ 55 /* OK, this is moderately ugly. But probably safe. Alternatives? */
56 if (memcmp(mtd->name, "DiskOnChip", 10)) 56 if (memcmp(mtd->name, "DiskOnChip", 10))
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index c5f4ebf4b384..46f27de018c3 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -50,7 +50,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
50 struct NFTLrecord *nftl; 50 struct NFTLrecord *nftl;
51 unsigned long temp; 51 unsigned long temp;
52 52
53 if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) 53 if (!mtd_type_is_nand(mtd) || mtd->size > UINT_MAX)
54 return; 54 return;
55 /* OK, this is moderately ugly. But probably safe. Alternatives? */ 55 /* OK, this is moderately ugly. But probably safe. Alternatives? */
56 if (memcmp(mtd->name, "DiskOnChip", 10)) 56 if (memcmp(mtd->name, "DiskOnChip", 10))
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
index ab2a52a039c3..daf82ba7aba0 100644
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -290,7 +290,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
290 int cis_sector; 290 int cis_sector;
291 291
292 /* Check for small page NAND flash */ 292 /* Check for small page NAND flash */
293 if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE || 293 if (!mtd_type_is_nand(mtd) || mtd->oobsize != OOB_SIZE ||
294 mtd->size > UINT_MAX) 294 mtd->size > UINT_MAX)
295 return; 295 return;
296 296
diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c
index 3cd3aabbe1cd..6f976159611f 100644
--- a/drivers/mtd/tests/nandbiterrs.c
+++ b/drivers/mtd/tests/nandbiterrs.c
@@ -349,7 +349,7 @@ static int __init mtd_nandbiterrs_init(void)
349 goto exit_mtddev; 349 goto exit_mtddev;
350 } 350 }
351 351
352 if (mtd->type != MTD_NANDFLASH) { 352 if (!mtd_type_is_nand(mtd)) {
353 pr_info("this test requires NAND flash\n"); 353 pr_info("this test requires NAND flash\n");
354 err = -ENODEV; 354 err = -ENODEV;
355 goto exit_nand; 355 goto exit_nand;
diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c
index ff35c465bfee..2e9e2d11f204 100644
--- a/drivers/mtd/tests/oobtest.c
+++ b/drivers/mtd/tests/oobtest.c
@@ -289,7 +289,7 @@ static int __init mtd_oobtest_init(void)
289 return err; 289 return err;
290 } 290 }
291 291
292 if (mtd->type != MTD_NANDFLASH) { 292 if (!mtd_type_is_nand(mtd)) {
293 pr_info("this test requires NAND flash\n"); 293 pr_info("this test requires NAND flash\n");
294 goto out; 294 goto out;
295 } 295 }
diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c
index 44b96e999ad4..ed2d3f656fd2 100644
--- a/drivers/mtd/tests/pagetest.c
+++ b/drivers/mtd/tests/pagetest.c
@@ -353,7 +353,7 @@ static int __init mtd_pagetest_init(void)
353 return err; 353 return err;
354 } 354 }
355 355
356 if (mtd->type != MTD_NANDFLASH) { 356 if (!mtd_type_is_nand(mtd)) {
357 pr_info("this test requires NAND flash\n"); 357 pr_info("this test requires NAND flash\n");
358 goto out; 358 goto out;
359 } 359 }
diff --git a/drivers/mtd/tests/subpagetest.c b/drivers/mtd/tests/subpagetest.c
index e2c0adf24cfc..a876371ad410 100644
--- a/drivers/mtd/tests/subpagetest.c
+++ b/drivers/mtd/tests/subpagetest.c
@@ -299,7 +299,7 @@ static int __init mtd_subpagetest_init(void)
299 return err; 299 return err;
300 } 300 }
301 301
302 if (mtd->type != MTD_NANDFLASH) { 302 if (!mtd_type_is_nand(mtd)) {
303 pr_info("this test requires NAND flash\n"); 303 pr_info("this test requires NAND flash\n");
304 goto out; 304 goto out;
305 } 305 }
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index f9bfe526d310..88409b813418 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -354,6 +354,11 @@ static inline int mtd_has_oob(const struct mtd_info *mtd)
354 return mtd->_read_oob && mtd->_write_oob; 354 return mtd->_read_oob && mtd->_write_oob;
355} 355}
356 356
357static inline int mtd_type_is_nand(const struct mtd_info *mtd)
358{
359 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
360}
361
357static inline int mtd_can_have_bb(const struct mtd_info *mtd) 362static inline int mtd_can_have_bb(const struct mtd_info *mtd)
358{ 363{
359 return !!mtd->_block_isbad; 364 return !!mtd->_block_isbad;