Commit 5942ddbc authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse

mtd: introduce mtd_block_markbad interface

Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 7086c19d
...@@ -424,7 +424,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block) ...@@ -424,7 +424,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
fail: fail:
/* could not format, update the bad block table (caller is responsible /* could not format, update the bad block table (caller is responsible
for setting the PUtable to BLOCK_RESERVED on failure) */ for setting the PUtable to BLOCK_RESERVED on failure) */
inftl->mbd.mtd->block_markbad(inftl->mbd.mtd, instr->addr); mtd_block_markbad(inftl->mbd.mtd, instr->addr);
return -1; return -1;
} }
......
...@@ -899,7 +899,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -899,7 +899,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
if (!mtd->block_markbad) if (!mtd->block_markbad)
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
else else
return mtd->block_markbad(mtd, offs); return mtd_block_markbad(mtd, offs);
break; break;
} }
......
...@@ -693,7 +693,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs) ...@@ -693,7 +693,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
continue; continue;
} }
err = subdev->block_markbad(subdev, ofs); err = mtd_block_markbad(subdev, ofs);
if (!err) if (!err)
mtd->ecc_stats.badblocks++; mtd->ecc_stats.badblocks++;
break; break;
......
...@@ -200,7 +200,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work) ...@@ -200,7 +200,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
} }
if (mtd->block_markbad && ret == -EIO) { if (mtd->block_markbad && ret == -EIO) {
ret = mtd->block_markbad(mtd, cxt->nextpage * record_size); ret = mtd_block_markbad(mtd, cxt->nextpage * record_size);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n"); printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n");
return; return;
......
...@@ -335,7 +335,7 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) ...@@ -335,7 +335,7 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
if (ofs >= mtd->size) if (ofs >= mtd->size)
return -EINVAL; return -EINVAL;
ofs += part->offset; ofs += part->offset;
res = part->master->block_markbad(part->master, ofs); res = mtd_block_markbad(part->master, ofs);
if (!res) if (!res)
mtd->ecc_stats.badblocks++; mtd->ecc_stats.badblocks++;
return res; return res;
......
...@@ -279,7 +279,7 @@ static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb) ...@@ -279,7 +279,7 @@ static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb)
offset = mtdswap_eb_offset(d, eb); offset = mtdswap_eb_offset(d, eb);
dev_warn(d->dev, "Marking bad block at %08llx\n", offset); dev_warn(d->dev, "Marking bad block at %08llx\n", offset);
ret = d->mtd->block_markbad(d->mtd, offset); ret = mtd_block_markbad(d->mtd, offset);
if (ret) { if (ret) {
dev_warn(d->dev, "Mark block bad failed for block at %08llx " dev_warn(d->dev, "Mark block bad failed for block at %08llx "
......
...@@ -737,7 +737,7 @@ static int parse_badblocks(struct nandsim *ns, struct mtd_info *mtd) ...@@ -737,7 +737,7 @@ static int parse_badblocks(struct nandsim *ns, struct mtd_info *mtd)
return -EINVAL; return -EINVAL;
} }
offset = erase_block_no * ns->geom.secsz; offset = erase_block_no * ns->geom.secsz;
if (mtd->block_markbad(mtd, offset)) { if (mtd_block_markbad(mtd, offset)) {
NS_ERR("invalid badblocks.\n"); NS_ERR("invalid badblocks.\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -356,7 +356,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block) ...@@ -356,7 +356,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
fail: fail:
/* could not format, update the bad block table (caller is responsible /* could not format, update the bad block table (caller is responsible
for setting the ReplUnitTable to BLOCK_RESERVED on failure) */ for setting the ReplUnitTable to BLOCK_RESERVED on failure) */
nftl->mbd.mtd->block_markbad(nftl->mbd.mtd, instr->addr); mtd_block_markbad(nftl->mbd.mtd, instr->addr);
return -1; return -1;
} }
......
...@@ -2645,7 +2645,7 @@ static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs) ...@@ -2645,7 +2645,7 @@ static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
} }
onenand_get_device(mtd, FL_WRITING); onenand_get_device(mtd, FL_WRITING);
ret = this->block_markbad(mtd, ofs); ret = mtd_block_markbad(mtd, ofs);
onenand_release_device(mtd); onenand_release_device(mtd);
return ret; return ret;
} }
......
...@@ -669,7 +669,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum) ...@@ -669,7 +669,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum)
if (!ubi->bad_allowed) if (!ubi->bad_allowed)
return 0; return 0;
err = mtd->block_markbad(mtd, (loff_t)pnum * ubi->peb_size); err = mtd_block_markbad(mtd, (loff_t)pnum * ubi->peb_size);
if (err) if (err)
ubi_err("cannot mark PEB %d bad, error %d", pnum, err); ubi_err("cannot mark PEB %d bad, error %d", pnum, err);
return err; return err;
......
...@@ -1134,7 +1134,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * ...@@ -1134,7 +1134,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *
return 1; // What else can we do? return 1; // What else can we do?
printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset);
ret = c->mtd->block_markbad(c->mtd, bad_offset); ret = mtd_block_markbad(c->mtd, bad_offset);
if (ret) { if (ret) {
D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret));
......
...@@ -211,6 +211,7 @@ struct mtd_info { ...@@ -211,6 +211,7 @@ struct mtd_info {
int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len); int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
int (*suspend) (struct mtd_info *mtd); int (*suspend) (struct mtd_info *mtd);
void (*resume) (struct mtd_info *mtd); void (*resume) (struct mtd_info *mtd);
...@@ -219,9 +220,6 @@ struct mtd_info { ...@@ -219,9 +220,6 @@ struct mtd_info {
*/ */
struct backing_dev_info *backing_dev_info; struct backing_dev_info *backing_dev_info;
/* Bad block management functions */
int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
struct notifier_block reboot_notifier; /* default mode before reboot */ struct notifier_block reboot_notifier; /* default mode before reboot */
/* ECC status information */ /* ECC status information */
...@@ -411,6 +409,11 @@ static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) ...@@ -411,6 +409,11 @@ static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
return mtd->block_isbad(mtd, ofs); return mtd->block_isbad(mtd, ofs);
} }
static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
{
return mtd->block_markbad(mtd, ofs);
}
static inline struct mtd_info *dev_to_mtd(struct device *dev) static inline struct mtd_info *dev_to_mtd(struct device *dev)
{ {
return dev ? dev_get_drvdata(dev) : NULL; return dev ? dev_get_drvdata(dev) : NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment