mtd: introduce mtd_block_isbad interface
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 23 Dec 2011 17:35:30 +0000 (19:35 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:25:47 +0000 (18:25 +0000)
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
21 files changed:
arch/cris/arch-v32/drivers/axisflashmap.c
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/nftlmount.c
drivers/mtd/redboot.c
drivers/mtd/ssfdc.c
drivers/mtd/tests/mtd_oobtest.c
drivers/mtd/tests/mtd_pagetest.c
drivers/mtd/tests/mtd_readtest.c
drivers/mtd/tests/mtd_speedtest.c
drivers/mtd/tests/mtd_stresstest.c
drivers/mtd/tests/mtd_subpagetest.c
drivers/mtd/tests/mtd_torturetest.c
drivers/mtd/ubi/io.c
fs/jffs2/scan.c
fs/logfs/dev_mtd.c
include/linux/mtd/mtd.h

index 011bddbf073f50ec4287c7b567cc51af85974e87..b34438e026be436d6c71632a250a23c187d9c6f7 100644 (file)
@@ -404,8 +404,7 @@ static int __init init_axis_flash(void)
                 */
                int blockstat;
                do {
-                       blockstat = main_mtd->block_isbad(main_mtd,
-                               ptable_sector);
+                       blockstat = mtd_block_isbad(main_mtd, ptable_sector);
                        if (blockstat < 0)
                                ptable_sector = 0; /* read error */
                        else if (blockstat)
index 9bfbca5d88d68dd1fe711e5d9397140d5fd5a5ac..38519401196bd5752dd68636440c74f38316e761 100644 (file)
@@ -306,7 +306,8 @@ static int find_boot_record(struct INFTLrecord *inftl)
                        /* If any of the physical eraseblocks are bad, don't
                           use the unit. */
                        for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) {
-                               if (inftl->mbd.mtd->block_isbad(inftl->mbd.mtd, i * inftl->EraseSize + physblock))
+                               if (mtd_block_isbad(inftl->mbd.mtd,
+                                                   i * inftl->EraseSize + physblock))
                                        inftl->PUtable[i] = BLOCK_RESERVED;
                        }
                }
index 6d598b23cf3a359cde1e26dbb1412a84b18105b1..a499bf7a82143c44ffd164051e43a89139534bfe 100644 (file)
@@ -886,7 +886,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
                if (!mtd->block_isbad)
                        ret = -EOPNOTSUPP;
                else
-                       return mtd->block_isbad(mtd, offs);
+                       return mtd_block_isbad(mtd, offs);
                break;
        }
 
index 4b7f825ce015298e2163bc22830ae695fd034ff6..d0db5e61d5af67242f5e1e1543ef14eb81385b14 100644 (file)
@@ -667,7 +667,7 @@ static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs)
                        continue;
                }
 
-               res = subdev->block_isbad(subdev, ofs);
+               res = mtd_block_isbad(subdev, ofs);
                break;
        }
 
index 7be2018ffbcc36edf4fe11e498a1a94ebd7b7678..bc43d2f7272c22e3e50ef0b8d78ede2031c90cf3 100644 (file)
@@ -170,7 +170,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
        }
 
        while (mtd->block_isbad) {
-               ret = mtd->block_isbad(mtd, cxt->nextpage * record_size);
+               ret = mtd_block_isbad(mtd, cxt->nextpage * record_size);
                if (!ret)
                        break;
                if (ret < 0) {
@@ -254,7 +254,7 @@ static void find_next_position(struct mtdoops_context *cxt)
 
        for (page = 0; page < cxt->oops_pages; page++) {
                if (mtd->block_isbad &&
-                   mtd->block_isbad(mtd, page * record_size))
+                   mtd_block_isbad(mtd, page * record_size))
                        continue;
                /* Assume the page is used */
                mark_page_used(cxt, page);
index 8610750852aca3f79710ebb89ddc9cade2bcf9b6..0e7dfc79d3376bd906281e9b1438a9bd22ce5e2d 100644 (file)
@@ -322,7 +322,7 @@ static int part_block_isbad(struct mtd_info *mtd, loff_t ofs)
        if (ofs >= mtd->size)
                return -EINVAL;
        ofs += part->offset;
-       return part->master->block_isbad(part->master, ofs);
+       return mtd_block_isbad(part->master, ofs);
 }
 
 static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
@@ -553,8 +553,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
                uint64_t offs = 0;
 
                while (offs < slave->mtd.size) {
-                       if (master->block_isbad(master,
-                                               offs + slave->offset))
+                       if (mtd_block_isbad(master, offs + slave->offset))
                                slave->mtd.ecc_stats.badblocks++;
                        offs += slave->mtd.erasesize;
                }
index cb794e761012d075163b64a7c6f7fbf6bcb4f551..87aa0a6323c3e43952f0889175f1e775ae11e6d9 100644 (file)
@@ -343,7 +343,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb)
        offset = mtdswap_eb_offset(d, eb);
 
        /* Check first if the block is bad. */
-       if (d->mtd->block_isbad && d->mtd->block_isbad(d->mtd, offset))
+       if (d->mtd->block_isbad && mtd_block_isbad(d->mtd, offset))
                return MTDSWAP_SCANNED_BAD;
 
        ops.ooblen = 2 * d->mtd->ecclayout->oobavail;
@@ -1061,7 +1061,7 @@ static unsigned int mtdswap_badblocks(struct mtd_info *mtd, uint64_t size)
 
        if (mtd->block_isbad)
                for (offset = 0; offset < size; offset += mtd->erasesize)
-                       if (mtd->block_isbad(mtd, offset))
+                       if (mtd_block_isbad(mtd, offset))
                                badcnt++;
 
        return badcnt;
index b068dc8a3666c1a28714560425c8628bda148911..156af9f87961f403c30a4949feffe3ff50e58515 100644 (file)
@@ -242,7 +242,8 @@ The new DiskOnChip driver already scanned the bad block table.  Just query it.
                        if (buf[i & (SECTORSIZE - 1)] != 0xff)
                                nftl->ReplUnitTable[i] = BLOCK_RESERVED;
 #endif
-                       if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize))
+                       if (mtd_block_isbad(nftl->mbd.mtd,
+                                           i * nftl->EraseSize))
                                nftl->ReplUnitTable[i] = BLOCK_RESERVED;
                }
 
index 623d9b86d0d9d75a0c50355d35fe9a8d9e8a39cb..09bb81ea3a7ebc8a631f8729c729cd70e98d6ddb 100644 (file)
@@ -79,7 +79,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
        if ( directory < 0 ) {
                offset = master->size + directory * master->erasesize;
                while (master->block_isbad && 
-                      master->block_isbad(master, offset)) {
+                      mtd_block_isbad(master, offset)) {
                        if (!offset) {
                        nogood:
                                printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
@@ -90,7 +90,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
        } else {
                offset = directory * master->erasesize;
                while (master->block_isbad && 
-                      master->block_isbad(master, offset)) {
+                      mtd_block_isbad(master, offset)) {
                        offset += master->erasesize;
                        if (offset == master->size)
                                goto nogood;
index 0e6881338357e5ab565d4412aa5587b25f127e08..ab2a52a039c3eef994e7e4a53645d34e1a059eb2 100644 (file)
@@ -122,7 +122,7 @@ static int get_valid_cis_sector(struct mtd_info *mtd)
         * is not SSFDC formatted
         */
        for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) {
-               if (!mtd->block_isbad(mtd, offset)) {
+               if (mtd_block_isbad(mtd, offset)) {
                        ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen,
                                       sect_buf);
 
@@ -255,7 +255,7 @@ static int build_logical_block_map(struct ssfdcr_record *ssfdc)
        for (phys_block = ssfdc->cis_block + 1; phys_block < ssfdc->map_len;
                        phys_block++) {
                offset = (unsigned long)phys_block * ssfdc->erase_size;
-               if (mtd->block_isbad(mtd, offset))
+               if (mtd_block_isbad(mtd, offset))
                        continue;       /* skip bad blocks */
 
                ret = read_raw_oob(mtd, offset, oob_buf);
index 81113885e086dbcb4c675a547ef31fd92cee4500..ed9b62827f1bee15e6f5236e4c47f92cae6bfd5c 100644 (file)
@@ -329,7 +329,7 @@ static int is_block_bad(int ebnum)
        int ret;
        loff_t addr = ebnum * mtd->erasesize;
 
-       ret = mtd->block_isbad(mtd, addr);
+       ret = mtd_block_isbad(mtd, addr);
        if (ret)
                printk(PRINT_PREF "block %d is bad\n", ebnum);
        return ret;
index 83da97e54f97efb8fb5dd67f03b4ae572982d1fb..8024eaf4c1acef53c94a6e06f4b441ba6509a66c 100644 (file)
@@ -469,7 +469,7 @@ static int is_block_bad(int ebnum)
        loff_t addr = ebnum * mtd->erasesize;
        int ret;
 
-       ret = mtd->block_isbad(mtd, addr);
+       ret = mtd_block_isbad(mtd, addr);
        if (ret)
                printk(PRINT_PREF "block %d is bad\n", ebnum);
        return ret;
index 5eaeada8428418abf26bac3b3e6db116fedd5fc1..ad5fd0df86ee925294f4fb1580480e7800e9a0dc 100644 (file)
@@ -132,7 +132,7 @@ static int is_block_bad(int ebnum)
        loff_t addr = ebnum * mtd->erasesize;
        int ret;
 
-       ret = mtd->block_isbad(mtd, addr);
+       ret = mtd_block_isbad(mtd, addr);
        if (ret)
                printk(PRINT_PREF "block %d is bad\n", ebnum);
        return ret;
index c7b18e189082ff2de210938e0ab2385933fbb68c..ecb287847505583166fafd3df31fc6b2ee50f72a 100644 (file)
@@ -296,7 +296,7 @@ static int is_block_bad(int ebnum)
        loff_t addr = ebnum * mtd->erasesize;
        int ret;
 
-       ret = mtd->block_isbad(mtd, addr);
+       ret = mtd_block_isbad(mtd, addr);
        if (ret)
                printk(PRINT_PREF "block %d is bad\n", ebnum);
        return ret;
index f8aac4b7e59a537be00a91dabb39745864ffa6ee..4789c0ee3e9a84b9bb972594b5a2ba88ea0d3f51 100644 (file)
@@ -132,7 +132,7 @@ static int is_block_bad(int ebnum)
        loff_t addr = ebnum * mtd->erasesize;
        int ret;
 
-       ret = mtd->block_isbad(mtd, addr);
+       ret = mtd_block_isbad(mtd, addr);
        if (ret)
                printk(PRINT_PREF "block %d is bad\n", ebnum);
        return ret;
index b90c01036b495133c0b155b8f38e2148660e9703..4b873d49fe6a6286d697822ec95ca54285a22e26 100644 (file)
@@ -344,7 +344,7 @@ static int is_block_bad(int ebnum)
        loff_t addr = ebnum * mtd->erasesize;
        int ret;
 
-       ret = mtd->block_isbad(mtd, addr);
+       ret = mtd_block_isbad(mtd, addr);
        if (ret)
                printk(PRINT_PREF "block %d is bad\n", ebnum);
        return ret;
index dd34a519fa7a84aed016daba2249fe6129e835c3..30c4ed9855ecfd005263da02ddafcf0d8b3937b5 100644 (file)
@@ -292,8 +292,7 @@ static int __init tort_init(void)
        memset(&bad_ebs[0], 0, sizeof(int) * ebcnt);
        if (mtd->block_isbad) {
                for (i = eb; i < eb + ebcnt; i++) {
-                       err = mtd->block_isbad(mtd,
-                                              (loff_t)i * mtd->erasesize);
+                       err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize);
 
                        if (err < 0) {
                                printk(PRINT_PREF "block_isbad() returned %d "
index 8d832fc9e9e4b046ed25080393fb45c569b4461f..a1b683ad639e28f35a4968beeae97849b0bd389d 100644 (file)
@@ -634,7 +634,7 @@ int ubi_io_is_bad(const struct ubi_device *ubi, int pnum)
        if (ubi->bad_allowed) {
                int ret;
 
-               ret = mtd->block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
+               ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
                if (ret < 0)
                        ubi_err("error %d while checking if PEB %d is bad",
                                ret, pnum);
index 72f3960f44a97a75ea15be02fd06e1486379c92b..83e1665e2574440500997c9dd89c145e83cdc136 100644 (file)
@@ -455,7 +455,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
        if (jffs2_cleanmarker_oob(c)) {
                int ret;
 
-               if (c->mtd->block_isbad(c->mtd, jeb->offset))
+               if (mtd_block_isbad(c->mtd, jeb->offset))
                        return BLK_STATE_BADBLOCK;
 
                ret = jffs2_check_nand_cleanmarker(c, jeb);
index 0ca7a07db6c11aeb8e27a947269a33ec69f35258..136c7360a9b6b75ed41292a23b299c7f9b445a60 100644 (file)
@@ -157,7 +157,7 @@ static struct page *logfs_mtd_find_first_sb(struct super_block *sb, u64 *ofs)
                return NULL;
 
        *ofs = 0;
-       while (mtd->block_isbad(mtd, *ofs)) {
+       while (mtd_block_isbad(mtd, *ofs)) {
                *ofs += mtd->erasesize;
                if (*ofs >= mtd->size)
                        return NULL;
@@ -177,7 +177,7 @@ static struct page *logfs_mtd_find_last_sb(struct super_block *sb, u64 *ofs)
                return NULL;
 
        *ofs = mtd->size - mtd->erasesize;
-       while (mtd->block_isbad(mtd, *ofs)) {
+       while (mtd_block_isbad(mtd, *ofs)) {
                *ofs -= mtd->erasesize;
                if (*ofs <= 0)
                        return NULL;
index d6b4aa17750506a2b2594daf3c772b8fbe6daf24..a307ad093a54f8449f05b39a01c9f24b25b55e70 100644 (file)
@@ -210,6 +210,7 @@ struct mtd_info {
        int (*lock) (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 (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
        int (*suspend) (struct mtd_info *mtd);
        void (*resume) (struct mtd_info *mtd);
 
@@ -219,7 +220,6 @@ struct mtd_info {
        struct backing_dev_info *backing_dev_info;
 
        /* Bad block management functions */
-       int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
        int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
 
        struct notifier_block reboot_notifier;  /* default mode before reboot */
@@ -406,6 +406,11 @@ static inline void mtd_resume(struct mtd_info *mtd)
        mtd->resume(mtd);
 }
 
+static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
+{
+       return mtd->block_isbad(mtd, ofs);
+}
+
 static inline struct mtd_info *dev_to_mtd(struct device *dev)
 {
        return dev ? dev_get_drvdata(dev) : NULL;