]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtd: do not use mtd->block_markbad directly
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 2 Jan 2012 11:59:12 +0000 (13:59 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:26:26 +0000 (18:26 +0000)
Instead, use the new 'mtd_can_have_bb()', or just rely on 'mtd_block_markbad()'
return code, which will be -EOPNOTSUPP if bad blocks are not supported.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtdchar.c
drivers/mtd/mtdconcat.c
drivers/mtd/mtdoops.c
drivers/mtd/mtdswap.c
fs/jffs2/wbuf.c
include/linux/mtd/mtd.h

index 64efcbf087e92d11012787bdc0873f4c863b36be..50c6a1e7f675cea884a5a0bbb71fb061bfdfe932 100644 (file)
@@ -877,10 +877,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
 
                if (copy_from_user(&offs, argp, sizeof(loff_t)))
                        return -EFAULT;
-               if (!mtd->block_markbad)
-                       ret = -EOPNOTSUPP;
-               else
-                       return mtd_block_markbad(mtd, offs);
+               return mtd_block_markbad(mtd, offs);
                break;
        }
 
index fbf3cb124a93f9779a70206382e0025ee2b2d95f..1ed5103b219ba3d51919b3ae285eb64f335e1af9 100644 (file)
@@ -673,7 +673,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
        struct mtd_concat *concat = CONCAT(mtd);
        int i, err = -EINVAL;
 
-       if (!concat->subdev[0]->block_markbad)
+       if (!mtd_can_have_bb(concat->subdev[0]))
                return 0;
 
        if (ofs > mtd->size)
index a4c8f67560e0eecd5494ced3561e8e4ac4bb0110..db8e8272d69b04d08aebbf99f6f668220e2b994a 100644 (file)
@@ -199,7 +199,7 @@ badblock:
                return;
        }
 
-       if (mtd->block_markbad && ret == -EIO) {
+       if (mtd_can_have_bb(mtd) && ret == -EIO) {
                ret = mtd_block_markbad(mtd, cxt->nextpage * record_size);
                if (ret < 0) {
                        printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n");
index 3fc8cb2756c0fac1064ca26315e2a771c703973a..c92f0f6bc130e12380a53eab2a53239be33916f1 100644 (file)
@@ -274,7 +274,7 @@ static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb)
        eb->root = NULL;
 
        /* badblocks not supported */
-       if (!d->mtd->block_markbad)
+       if (!mtd_can_have_bb(d->mtd))
                return 1;
 
        offset = mtdswap_eb_offset(d, eb);
index fd96b757433fa85add64598aac09de0d5be5d3ba..30e8f47e8a233f32ad7eaab70dfbf1291bcf409b 100644 (file)
@@ -1130,9 +1130,6 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *
        if( ++jeb->bad_count < MAX_ERASE_FAILURES)
                return 0;
 
-       if (!c->mtd->block_markbad)
-               return 1; // What else can we do?
-
        printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset);
        ret = mtd_block_markbad(c->mtd, bad_offset);
 
index 7e35755f69311eb4ccadcf54a115b9ba8d5a044f..1a81fde8f3331d9652054325aa36809cb40b45f1 100644 (file)
@@ -447,6 +447,8 @@ static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
 
 static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
 {
+       if (!mtd->block_markbad)
+               return -EOPNOTSUPP;
        return mtd->block_markbad(mtd, ofs);
 }