diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-01-02 06:48:54 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:24 -0500 |
commit | 8f461a730242c528ca221948edceca49266a3ffb (patch) | |
tree | 232b1d9ac6a74df87a84c9e1e6a61415afc9f583 /drivers/mtd | |
parent | 079c985e7a6f4ce60f931cebfdd5ee3c38347e31 (diff) |
mtd: introduce mtd_can_have_bb helper
This patch introduces new 'mtd_can_have_bb()' helper function which checks
whether the flash can have bad eraseblocks. Then it changes all the
direct 'mtd->block_isbad' use cases with 'mtd_can_have_bb()'.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdchar.c | 5 | ||||
-rw-r--r-- | drivers/mtd/mtdconcat.c | 2 | ||||
-rw-r--r-- | drivers/mtd/mtdoops.c | 4 | ||||
-rw-r--r-- | drivers/mtd/mtdswap.c | 4 | ||||
-rw-r--r-- | drivers/mtd/nftlcore.c | 2 | ||||
-rw-r--r-- | drivers/mtd/redboot.c | 4 | ||||
-rw-r--r-- | drivers/mtd/tests/mtd_readtest.c | 3 | ||||
-rw-r--r-- | drivers/mtd/tests/mtd_speedtest.c | 3 | ||||
-rw-r--r-- | drivers/mtd/tests/mtd_stresstest.c | 3 | ||||
-rw-r--r-- | drivers/mtd/tests/mtd_torturetest.c | 2 | ||||
-rw-r--r-- | drivers/mtd/ubi/build.c | 2 |
11 files changed, 14 insertions, 20 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 92da621b1425..64efcbf087e9 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -867,10 +867,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
867 | 867 | ||
868 | if (copy_from_user(&offs, argp, sizeof(loff_t))) | 868 | if (copy_from_user(&offs, argp, sizeof(loff_t))) |
869 | return -EFAULT; | 869 | return -EFAULT; |
870 | if (!mtd->block_isbad) | 870 | return mtd_block_isbad(mtd, offs); |
871 | ret = -EOPNOTSUPP; | ||
872 | else | ||
873 | return mtd_block_isbad(mtd, offs); | ||
874 | break; | 871 | break; |
875 | } | 872 | } |
876 | 873 | ||
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index aaafb5e18765..fbf3cb124a93 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -647,7 +647,7 @@ static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs) | |||
647 | struct mtd_concat *concat = CONCAT(mtd); | 647 | struct mtd_concat *concat = CONCAT(mtd); |
648 | int i, res = 0; | 648 | int i, res = 0; |
649 | 649 | ||
650 | if (!concat->subdev[0]->block_isbad) | 650 | if (!mtd_can_have_bb(concat->subdev[0])) |
651 | return res; | 651 | return res; |
652 | 652 | ||
653 | if (ofs > mtd->size) | 653 | if (ofs > mtd->size) |
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index c8540b8a7fc6..a4c8f67560e0 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
@@ -169,7 +169,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work) | |||
169 | cxt->nextpage = 0; | 169 | cxt->nextpage = 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | while (mtd->block_isbad) { | 172 | while (mtd_can_have_bb(mtd)) { |
173 | ret = mtd_block_isbad(mtd, cxt->nextpage * record_size); | 173 | ret = mtd_block_isbad(mtd, cxt->nextpage * record_size); |
174 | if (!ret) | 174 | if (!ret) |
175 | break; | 175 | break; |
@@ -257,7 +257,7 @@ static void find_next_position(struct mtdoops_context *cxt) | |||
257 | size_t retlen; | 257 | size_t retlen; |
258 | 258 | ||
259 | for (page = 0; page < cxt->oops_pages; page++) { | 259 | for (page = 0; page < cxt->oops_pages; page++) { |
260 | if (mtd->block_isbad && | 260 | if (mtd_can_have_bb(mtd) && |
261 | mtd_block_isbad(mtd, page * record_size)) | 261 | mtd_block_isbad(mtd, page * record_size)) |
262 | continue; | 262 | continue; |
263 | /* Assume the page is used */ | 263 | /* Assume the page is used */ |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index fe4426c1c736..3fc8cb2756c0 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c | |||
@@ -343,7 +343,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb) | |||
343 | offset = mtdswap_eb_offset(d, eb); | 343 | offset = mtdswap_eb_offset(d, eb); |
344 | 344 | ||
345 | /* Check first if the block is bad. */ | 345 | /* Check first if the block is bad. */ |
346 | if (d->mtd->block_isbad && mtd_block_isbad(d->mtd, offset)) | 346 | if (mtd_can_have_bb(d->mtd) && mtd_block_isbad(d->mtd, offset)) |
347 | return MTDSWAP_SCANNED_BAD; | 347 | return MTDSWAP_SCANNED_BAD; |
348 | 348 | ||
349 | ops.ooblen = 2 * d->mtd->ecclayout->oobavail; | 349 | ops.ooblen = 2 * d->mtd->ecclayout->oobavail; |
@@ -1058,7 +1058,7 @@ static unsigned int mtdswap_badblocks(struct mtd_info *mtd, uint64_t size) | |||
1058 | 1058 | ||
1059 | badcnt = 0; | 1059 | badcnt = 0; |
1060 | 1060 | ||
1061 | if (mtd->block_isbad) | 1061 | if (mtd_can_have_bb(mtd)) |
1062 | for (offset = 0; offset < size; offset += mtd->erasesize) | 1062 | for (offset = 0; offset < size; offset += mtd->erasesize) |
1063 | if (mtd_block_isbad(mtd, offset)) | 1063 | if (mtd_block_isbad(mtd, offset)) |
1064 | badcnt++; | 1064 | badcnt++; |
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index 8847e60ad167..a75382aff5f6 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -56,7 +56,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
56 | if (memcmp(mtd->name, "DiskOnChip", 10)) | 56 | if (memcmp(mtd->name, "DiskOnChip", 10)) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | if (!mtd->block_isbad) { | 59 | if (!mtd_can_have_bb(mtd)) { |
60 | printk(KERN_ERR | 60 | printk(KERN_ERR |
61 | "NFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n" | 61 | "NFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n" |
62 | "Please use the new diskonchip driver under the NAND subsystem.\n"); | 62 | "Please use the new diskonchip driver under the NAND subsystem.\n"); |
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 09bb81ea3a7e..48970c14beff 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -78,7 +78,7 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
78 | 78 | ||
79 | if ( directory < 0 ) { | 79 | if ( directory < 0 ) { |
80 | offset = master->size + directory * master->erasesize; | 80 | offset = master->size + directory * master->erasesize; |
81 | while (master->block_isbad && | 81 | while (mtd_can_have_bb(master) && |
82 | mtd_block_isbad(master, offset)) { | 82 | mtd_block_isbad(master, offset)) { |
83 | if (!offset) { | 83 | if (!offset) { |
84 | nogood: | 84 | nogood: |
@@ -89,7 +89,7 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
89 | } | 89 | } |
90 | } else { | 90 | } else { |
91 | offset = directory * master->erasesize; | 91 | offset = directory * master->erasesize; |
92 | while (master->block_isbad && | 92 | while (mtd_can_have_bb(master) && |
93 | mtd_block_isbad(master, offset)) { | 93 | mtd_block_isbad(master, offset)) { |
94 | offset += master->erasesize; | 94 | offset += master->erasesize; |
95 | if (offset == master->size) | 95 | if (offset == master->size) |
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c index 4228eb4e54c7..121aba189cec 100644 --- a/drivers/mtd/tests/mtd_readtest.c +++ b/drivers/mtd/tests/mtd_readtest.c | |||
@@ -148,8 +148,7 @@ static int scan_for_bad_eraseblocks(void) | |||
148 | return -ENOMEM; | 148 | return -ENOMEM; |
149 | } | 149 | } |
150 | 150 | ||
151 | /* NOR flash does not implement block_isbad */ | 151 | if (!mtd_can_have_bb(mtd)) |
152 | if (mtd->block_isbad == NULL) | ||
153 | return 0; | 152 | return 0; |
154 | 153 | ||
155 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); | 154 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); |
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index 4d2ed5c0807d..2aec4f3b72be 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c | |||
@@ -336,8 +336,7 @@ static int scan_for_bad_eraseblocks(void) | |||
336 | return -ENOMEM; | 336 | return -ENOMEM; |
337 | } | 337 | } |
338 | 338 | ||
339 | /* NOR flash does not implement block_isbad */ | 339 | if (!mtd_can_have_bb(mtd)) |
340 | if (mtd->block_isbad == NULL) | ||
341 | goto out; | 340 | goto out; |
342 | 341 | ||
343 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); | 342 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); |
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c index 399aa2bf220d..7b33f22d0b58 100644 --- a/drivers/mtd/tests/mtd_stresstest.c +++ b/drivers/mtd/tests/mtd_stresstest.c | |||
@@ -227,8 +227,7 @@ static int scan_for_bad_eraseblocks(void) | |||
227 | return -ENOMEM; | 227 | return -ENOMEM; |
228 | } | 228 | } |
229 | 229 | ||
230 | /* NOR flash does not implement block_isbad */ | 230 | if (!mtd_can_have_bb(mtd)) |
231 | if (mtd->block_isbad == NULL) | ||
232 | return 0; | 231 | return 0; |
233 | 232 | ||
234 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); | 233 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); |
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c index 557105f2ead3..b65861bc7b8e 100644 --- a/drivers/mtd/tests/mtd_torturetest.c +++ b/drivers/mtd/tests/mtd_torturetest.c | |||
@@ -290,7 +290,7 @@ static int __init tort_init(void) | |||
290 | * Check if there is a bad eraseblock among those we are going to test. | 290 | * Check if there is a bad eraseblock among those we are going to test. |
291 | */ | 291 | */ |
292 | memset(&bad_ebs[0], 0, sizeof(int) * ebcnt); | 292 | memset(&bad_ebs[0], 0, sizeof(int) * ebcnt); |
293 | if (mtd->block_isbad) { | 293 | if (mtd_can_have_bb(mtd)) { |
294 | for (i = eb; i < eb + ebcnt; i++) { | 294 | for (i = eb; i < eb + ebcnt; i++) { |
295 | err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize); | 295 | err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize); |
296 | 296 | ||
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 6c3fb5ab20f5..115749f20f9e 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -664,7 +664,7 @@ static int io_init(struct ubi_device *ubi) | |||
664 | ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); | 664 | ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); |
665 | ubi->flash_size = ubi->mtd->size; | 665 | ubi->flash_size = ubi->mtd->size; |
666 | 666 | ||
667 | if (ubi->mtd->block_isbad && ubi->mtd->block_markbad) | 667 | if (mtd_can_have_bb(ubi->mtd)) |
668 | ubi->bad_allowed = 1; | 668 | ubi->bad_allowed = 1; |
669 | 669 | ||
670 | if (ubi->mtd->type == MTD_NORFLASH) { | 670 | if (ubi->mtd->type == MTD_NORFLASH) { |