diff options
| author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-23 12:37:38 -0500 |
|---|---|---|
| committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:25:48 -0500 |
| commit | 5942ddbc500d1c9b75e571b656be97f65b26adfe (patch) | |
| tree | 7e96cfb905fb67bc40e1da30eb8454d674353a36 | |
| parent | 7086c19d07429d697057587caf1e5e0345442d16 (diff) | |
mtd: introduce mtd_block_markbad interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
| -rw-r--r-- | drivers/mtd/inftlmount.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/mtdchar.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/mtdconcat.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/mtdoops.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/mtdpart.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/mtdswap.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/nand/nandsim.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/nftlmount.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/ubi/io.c | 2 | ||||
| -rw-r--r-- | fs/jffs2/wbuf.c | 2 | ||||
| -rw-r--r-- | include/linux/mtd/mtd.h | 9 |
12 files changed, 17 insertions, 14 deletions
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index 38519401196b..4adc0374fb6b 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c | |||
| @@ -424,7 +424,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block) | |||
| 424 | fail: | 424 | fail: |
| 425 | /* could not format, update the bad block table (caller is responsible | 425 | /* could not format, update the bad block table (caller is responsible |
| 426 | for setting the PUtable to BLOCK_RESERVED on failure) */ | 426 | for setting the PUtable to BLOCK_RESERVED on failure) */ |
| 427 | inftl->mbd.mtd->block_markbad(inftl->mbd.mtd, instr->addr); | 427 | mtd_block_markbad(inftl->mbd.mtd, instr->addr); |
| 428 | return -1; | 428 | return -1; |
| 429 | } | 429 | } |
| 430 | 430 | ||
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index a499bf7a8214..15a3f6224be4 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
| @@ -899,7 +899,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
| 899 | if (!mtd->block_markbad) | 899 | if (!mtd->block_markbad) |
| 900 | ret = -EOPNOTSUPP; | 900 | ret = -EOPNOTSUPP; |
| 901 | else | 901 | else |
| 902 | return mtd->block_markbad(mtd, offs); | 902 | return mtd_block_markbad(mtd, offs); |
| 903 | break; | 903 | break; |
| 904 | } | 904 | } |
| 905 | 905 | ||
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index d0db5e61d5af..f694b51e7856 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
| @@ -693,7 +693,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
| 693 | continue; | 693 | continue; |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | err = subdev->block_markbad(subdev, ofs); | 696 | err = mtd_block_markbad(subdev, ofs); |
| 697 | if (!err) | 697 | if (!err) |
| 698 | mtd->ecc_stats.badblocks++; | 698 | mtd->ecc_stats.badblocks++; |
| 699 | break; | 699 | break; |
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index bc43d2f7272c..69532a34e563 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
| @@ -200,7 +200,7 @@ badblock: | |||
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | if (mtd->block_markbad && ret == -EIO) { | 202 | if (mtd->block_markbad && ret == -EIO) { |
| 203 | ret = mtd->block_markbad(mtd, cxt->nextpage * record_size); | 203 | ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); |
| 204 | if (ret < 0) { | 204 | if (ret < 0) { |
| 205 | printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n"); | 205 | printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n"); |
| 206 | return; | 206 | return; |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 0e7dfc79d337..a3d44c3416b4 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
| @@ -335,7 +335,7 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
| 335 | if (ofs >= mtd->size) | 335 | if (ofs >= mtd->size) |
| 336 | return -EINVAL; | 336 | return -EINVAL; |
| 337 | ofs += part->offset; | 337 | ofs += part->offset; |
| 338 | res = part->master->block_markbad(part->master, ofs); | 338 | res = mtd_block_markbad(part->master, ofs); |
| 339 | if (!res) | 339 | if (!res) |
| 340 | mtd->ecc_stats.badblocks++; | 340 | mtd->ecc_stats.badblocks++; |
| 341 | return res; | 341 | return res; |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 87aa0a6323c3..4441c08b082d 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c | |||
| @@ -279,7 +279,7 @@ static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb) | |||
| 279 | 279 | ||
| 280 | offset = mtdswap_eb_offset(d, eb); | 280 | offset = mtdswap_eb_offset(d, eb); |
| 281 | dev_warn(d->dev, "Marking bad block at %08llx\n", offset); | 281 | dev_warn(d->dev, "Marking bad block at %08llx\n", offset); |
| 282 | ret = d->mtd->block_markbad(d->mtd, offset); | 282 | ret = mtd_block_markbad(d->mtd, offset); |
| 283 | 283 | ||
| 284 | if (ret) { | 284 | if (ret) { |
| 285 | dev_warn(d->dev, "Mark block bad failed for block at %08llx " | 285 | dev_warn(d->dev, "Mark block bad failed for block at %08llx " |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index 34c03be77301..261f478f8cc3 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
| @@ -737,7 +737,7 @@ static int parse_badblocks(struct nandsim *ns, struct mtd_info *mtd) | |||
| 737 | return -EINVAL; | 737 | return -EINVAL; |
| 738 | } | 738 | } |
| 739 | offset = erase_block_no * ns->geom.secsz; | 739 | offset = erase_block_no * ns->geom.secsz; |
| 740 | if (mtd->block_markbad(mtd, offset)) { | 740 | if (mtd_block_markbad(mtd, offset)) { |
| 741 | NS_ERR("invalid badblocks.\n"); | 741 | NS_ERR("invalid badblocks.\n"); |
| 742 | return -EINVAL; | 742 | return -EINVAL; |
| 743 | } | 743 | } |
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c index 156af9f87961..51b9d6af307f 100644 --- a/drivers/mtd/nftlmount.c +++ b/drivers/mtd/nftlmount.c | |||
| @@ -356,7 +356,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block) | |||
| 356 | fail: | 356 | fail: |
| 357 | /* could not format, update the bad block table (caller is responsible | 357 | /* could not format, update the bad block table (caller is responsible |
| 358 | for setting the ReplUnitTable to BLOCK_RESERVED on failure) */ | 358 | for setting the ReplUnitTable to BLOCK_RESERVED on failure) */ |
| 359 | nftl->mbd.mtd->block_markbad(nftl->mbd.mtd, instr->addr); | 359 | mtd_block_markbad(nftl->mbd.mtd, instr->addr); |
| 360 | return -1; | 360 | return -1; |
| 361 | } | 361 | } |
| 362 | 362 | ||
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index a8394730b4b6..dd278a284136 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
| @@ -2645,7 +2645,7 @@ static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
| 2645 | } | 2645 | } |
| 2646 | 2646 | ||
| 2647 | onenand_get_device(mtd, FL_WRITING); | 2647 | onenand_get_device(mtd, FL_WRITING); |
| 2648 | ret = this->block_markbad(mtd, ofs); | 2648 | ret = mtd_block_markbad(mtd, ofs); |
| 2649 | onenand_release_device(mtd); | 2649 | onenand_release_device(mtd); |
| 2650 | return ret; | 2650 | return ret; |
| 2651 | } | 2651 | } |
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index a1b683ad639e..5cde4e5ca3e5 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
| @@ -669,7 +669,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum) | |||
| 669 | if (!ubi->bad_allowed) | 669 | if (!ubi->bad_allowed) |
| 670 | return 0; | 670 | return 0; |
| 671 | 671 | ||
| 672 | err = mtd->block_markbad(mtd, (loff_t)pnum * ubi->peb_size); | 672 | err = mtd_block_markbad(mtd, (loff_t)pnum * ubi->peb_size); |
| 673 | if (err) | 673 | if (err) |
| 674 | ubi_err("cannot mark PEB %d bad, error %d", pnum, err); | 674 | ubi_err("cannot mark PEB %d bad, error %d", pnum, err); |
| 675 | return err; | 675 | return err; |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index eae5be483682..fd96b757433f 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
| @@ -1134,7 +1134,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
| 1134 | return 1; // What else can we do? | 1134 | return 1; // What else can we do? |
| 1135 | 1135 | ||
| 1136 | printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); | 1136 | printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); |
| 1137 | ret = c->mtd->block_markbad(c->mtd, bad_offset); | 1137 | ret = mtd_block_markbad(c->mtd, bad_offset); |
| 1138 | 1138 | ||
| 1139 | if (ret) { | 1139 | if (ret) { |
| 1140 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1140 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index a307ad093a54..64aa54fba2df 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
| @@ -211,6 +211,7 @@ struct mtd_info { | |||
| 211 | int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); | 211 | int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); |
| 212 | int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len); | 212 | int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len); |
| 213 | int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); | 213 | int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); |
| 214 | int (*block_markbad) (struct mtd_info *mtd, loff_t ofs); | ||
| 214 | int (*suspend) (struct mtd_info *mtd); | 215 | int (*suspend) (struct mtd_info *mtd); |
| 215 | void (*resume) (struct mtd_info *mtd); | 216 | void (*resume) (struct mtd_info *mtd); |
| 216 | 217 | ||
| @@ -219,9 +220,6 @@ struct mtd_info { | |||
| 219 | */ | 220 | */ |
| 220 | struct backing_dev_info *backing_dev_info; | 221 | struct backing_dev_info *backing_dev_info; |
| 221 | 222 | ||
| 222 | /* Bad block management functions */ | ||
| 223 | int (*block_markbad) (struct mtd_info *mtd, loff_t ofs); | ||
| 224 | |||
| 225 | struct notifier_block reboot_notifier; /* default mode before reboot */ | 223 | struct notifier_block reboot_notifier; /* default mode before reboot */ |
| 226 | 224 | ||
| 227 | /* ECC status information */ | 225 | /* ECC status information */ |
| @@ -411,6 +409,11 @@ static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) | |||
| 411 | return mtd->block_isbad(mtd, ofs); | 409 | return mtd->block_isbad(mtd, ofs); |
| 412 | } | 410 | } |
| 413 | 411 | ||
| 412 | static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) | ||
| 413 | { | ||
| 414 | return mtd->block_markbad(mtd, ofs); | ||
| 415 | } | ||
| 416 | |||
| 414 | static inline struct mtd_info *dev_to_mtd(struct device *dev) | 417 | static inline struct mtd_info *dev_to_mtd(struct device *dev) |
| 415 | { | 418 | { |
| 416 | return dev ? dev_get_drvdata(dev) : NULL; | 419 | return dev ? dev_get_drvdata(dev) : NULL; |
