mtd: introduce mtd_block_markbad interface
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 23 Dec 2011 17:37:38 +0000 (19:37 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:25:48 +0000 (18:25 +0000)
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 files changed:
drivers/mtd/inftlmount.c
drivers/mtd/mtdchar.c
drivers/mtd/mtdconcat.c
drivers/mtd/mtdoops.c
drivers/mtd/mtdpart.c
drivers/mtd/mtdswap.c
drivers/mtd/nand/nandsim.c
drivers/mtd/nftlmount.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/ubi/io.c
fs/jffs2/wbuf.c
include/linux/mtd/mtd.h

index 38519401196bd5752dd68636440c74f38316e761..4adc0374fb6b5736ba23cdc77f5f8ebb2bb7117b 100644 (file)
@@ -424,7 +424,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
 fail:
        /* could not format, update the bad block table (caller is responsible
           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;
 }
 
index a499bf7a82143c44ffd164051e43a89139534bfe..15a3f6224be46779c989e6327dfae9c27eb41ebb 100644 (file)
@@ -899,7 +899,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
                if (!mtd->block_markbad)
                        ret = -EOPNOTSUPP;
                else
-                       return mtd->block_markbad(mtd, offs);
+                       return mtd_block_markbad(mtd, offs);
                break;
        }
 
index d0db5e61d5af67242f5e1e1543ef14eb81385b14..f694b51e7856eb0bee70879983d86fa3b8df7e13 100644 (file)
@@ -693,7 +693,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
                        continue;
                }
 
-               err = subdev->block_markbad(subdev, ofs);
+               err = mtd_block_markbad(subdev, ofs);
                if (!err)
                        mtd->ecc_stats.badblocks++;
                break;
index bc43d2f7272c22e3e50ef0b8d78ede2031c90cf3..69532a34e563f83df36eb58bb3a0864b17ea78c1 100644 (file)
@@ -200,7 +200,7 @@ badblock:
        }
 
        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) {
                        printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n");
                        return;
index 0e7dfc79d3376bd906281e9b1438a9bd22ce5e2d..a3d44c3416b4f2bef8a1932976b2825a1e230609 100644 (file)
@@ -335,7 +335,7 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
        if (ofs >= mtd->size)
                return -EINVAL;
        ofs += part->offset;
-       res = part->master->block_markbad(part->master, ofs);
+       res = mtd_block_markbad(part->master, ofs);
        if (!res)
                mtd->ecc_stats.badblocks++;
        return res;
index 87aa0a6323c3e43952f0889175f1e775ae11e6d9..4441c08b082d9ca797fde51afd84d7a2c89594e9 100644 (file)
@@ -279,7 +279,7 @@ static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb)
 
        offset = mtdswap_eb_offset(d, eb);
        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) {
                dev_warn(d->dev, "Mark block bad failed for block at %08llx "
index 34c03be7730105c3a26867637700f8c0ade83219..261f478f8cc37944e3365ce8b0219ec073bfcddc 100644 (file)
@@ -737,7 +737,7 @@ static int parse_badblocks(struct nandsim *ns, struct mtd_info *mtd)
                        return -EINVAL;
                }
                offset = erase_block_no * ns->geom.secsz;
-               if (mtd->block_markbad(mtd, offset)) {
+               if (mtd_block_markbad(mtd, offset)) {
                        NS_ERR("invalid badblocks.\n");
                        return -EINVAL;
                }
index 156af9f87961f403c30a4949feffe3ff50e58515..51b9d6af307f616193ebc006b492a5fecedd535b 100644 (file)
@@ -356,7 +356,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
 fail:
        /* could not format, update the bad block table (caller is responsible
           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;
 }
 
index a8394730b4b6fc7e9e84fcdd919e9a09c0b669da..dd278a28413622d71074560ffd9cfcbefb8d46d8 100644 (file)
@@ -2645,7 +2645,7 @@ static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
        }
 
        onenand_get_device(mtd, FL_WRITING);
-       ret = this->block_markbad(mtd, ofs);
+       ret = mtd_block_markbad(mtd, ofs);
        onenand_release_device(mtd);
        return ret;
 }
index a1b683ad639e28f35a4968beeae97849b0bd389d..5cde4e5ca3e542a38945be3d12f106b4c3853e80 100644 (file)
@@ -669,7 +669,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum)
        if (!ubi->bad_allowed)
                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)
                ubi_err("cannot mark PEB %d bad, error %d", pnum, err);
        return err;
index eae5be4836822ce836bc6f9803f7734780213955..fd96b757433fa85add64598aac09de0d5be5d3ba 100644 (file)
@@ -1134,7 +1134,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *
                return 1; // What else can we do?
 
        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) {
                D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret));
index a307ad093a54f8449f05b39a01c9f24b25b55e70..64aa54fba2dfec67d879d566f656c42759080b1a 100644 (file)
@@ -211,6 +211,7 @@ struct mtd_info {
        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 (*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);
        void (*resume) (struct mtd_info *mtd);
 
@@ -219,9 +220,6 @@ struct mtd_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 */
 
        /* ECC status information */
@@ -411,6 +409,11 @@ static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t 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)
 {
        return dev ? dev_get_drvdata(dev) : NULL;