Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: introduce mtd_block_isbad interface

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Artem Bityutskiy and committed by
David Woodhouse
7086c19d ead995f8

+34 -30
+1 -2
arch/cris/arch-v32/drivers/axisflashmap.c
··· 404 404 */ 405 405 int blockstat; 406 406 do { 407 - blockstat = main_mtd->block_isbad(main_mtd, 408 - ptable_sector); 407 + blockstat = mtd_block_isbad(main_mtd, ptable_sector); 409 408 if (blockstat < 0) 410 409 ptable_sector = 0; /* read error */ 411 410 else if (blockstat)
+2 -1
drivers/mtd/inftlmount.c
··· 306 306 /* If any of the physical eraseblocks are bad, don't 307 307 use the unit. */ 308 308 for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) { 309 - if (inftl->mbd.mtd->block_isbad(inftl->mbd.mtd, i * inftl->EraseSize + physblock)) 309 + if (mtd_block_isbad(inftl->mbd.mtd, 310 + i * inftl->EraseSize + physblock)) 310 311 inftl->PUtable[i] = BLOCK_RESERVED; 311 312 } 312 313 }
+1 -1
drivers/mtd/mtdchar.c
··· 886 886 if (!mtd->block_isbad) 887 887 ret = -EOPNOTSUPP; 888 888 else 889 - return mtd->block_isbad(mtd, offs); 889 + return mtd_block_isbad(mtd, offs); 890 890 break; 891 891 } 892 892
+1 -1
drivers/mtd/mtdconcat.c
··· 667 667 continue; 668 668 } 669 669 670 - res = subdev->block_isbad(subdev, ofs); 670 + res = mtd_block_isbad(subdev, ofs); 671 671 break; 672 672 } 673 673
+2 -2
drivers/mtd/mtdoops.c
··· 170 170 } 171 171 172 172 while (mtd->block_isbad) { 173 - ret = mtd->block_isbad(mtd, cxt->nextpage * record_size); 173 + ret = mtd_block_isbad(mtd, cxt->nextpage * record_size); 174 174 if (!ret) 175 175 break; 176 176 if (ret < 0) { ··· 254 254 255 255 for (page = 0; page < cxt->oops_pages; page++) { 256 256 if (mtd->block_isbad && 257 - mtd->block_isbad(mtd, page * record_size)) 257 + mtd_block_isbad(mtd, page * record_size)) 258 258 continue; 259 259 /* Assume the page is used */ 260 260 mark_page_used(cxt, page);
+2 -3
drivers/mtd/mtdpart.c
··· 322 322 if (ofs >= mtd->size) 323 323 return -EINVAL; 324 324 ofs += part->offset; 325 - return part->master->block_isbad(part->master, ofs); 325 + return mtd_block_isbad(part->master, ofs); 326 326 } 327 327 328 328 static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) ··· 553 553 uint64_t offs = 0; 554 554 555 555 while (offs < slave->mtd.size) { 556 - if (master->block_isbad(master, 557 - offs + slave->offset)) 556 + if (mtd_block_isbad(master, offs + slave->offset)) 558 557 slave->mtd.ecc_stats.badblocks++; 559 558 offs += slave->mtd.erasesize; 560 559 }
+2 -2
drivers/mtd/mtdswap.c
··· 343 343 offset = mtdswap_eb_offset(d, eb); 344 344 345 345 /* Check first if the block is bad. */ 346 - if (d->mtd->block_isbad && d->mtd->block_isbad(d->mtd, offset)) 346 + if (d->mtd->block_isbad && mtd_block_isbad(d->mtd, offset)) 347 347 return MTDSWAP_SCANNED_BAD; 348 348 349 349 ops.ooblen = 2 * d->mtd->ecclayout->oobavail; ··· 1061 1061 1062 1062 if (mtd->block_isbad) 1063 1063 for (offset = 0; offset < size; offset += mtd->erasesize) 1064 - if (mtd->block_isbad(mtd, offset)) 1064 + if (mtd_block_isbad(mtd, offset)) 1065 1065 badcnt++; 1066 1066 1067 1067 return badcnt;
+2 -1
drivers/mtd/nftlmount.c
··· 242 242 if (buf[i & (SECTORSIZE - 1)] != 0xff) 243 243 nftl->ReplUnitTable[i] = BLOCK_RESERVED; 244 244 #endif 245 - if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize)) 245 + if (mtd_block_isbad(nftl->mbd.mtd, 246 + i * nftl->EraseSize)) 246 247 nftl->ReplUnitTable[i] = BLOCK_RESERVED; 247 248 } 248 249
+2 -2
drivers/mtd/redboot.c
··· 79 79 if ( directory < 0 ) { 80 80 offset = master->size + directory * master->erasesize; 81 81 while (master->block_isbad && 82 - master->block_isbad(master, offset)) { 82 + mtd_block_isbad(master, offset)) { 83 83 if (!offset) { 84 84 nogood: 85 85 printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n"); ··· 90 90 } else { 91 91 offset = directory * master->erasesize; 92 92 while (master->block_isbad && 93 - master->block_isbad(master, offset)) { 93 + mtd_block_isbad(master, offset)) { 94 94 offset += master->erasesize; 95 95 if (offset == master->size) 96 96 goto nogood;
+2 -2
drivers/mtd/ssfdc.c
··· 122 122 * is not SSFDC formatted 123 123 */ 124 124 for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { 125 - if (!mtd->block_isbad(mtd, offset)) { 125 + if (mtd_block_isbad(mtd, offset)) { 126 126 ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, 127 127 sect_buf); 128 128 ··· 255 255 for (phys_block = ssfdc->cis_block + 1; phys_block < ssfdc->map_len; 256 256 phys_block++) { 257 257 offset = (unsigned long)phys_block * ssfdc->erase_size; 258 - if (mtd->block_isbad(mtd, offset)) 258 + if (mtd_block_isbad(mtd, offset)) 259 259 continue; /* skip bad blocks */ 260 260 261 261 ret = read_raw_oob(mtd, offset, oob_buf);
+1 -1
drivers/mtd/tests/mtd_oobtest.c
··· 329 329 int ret; 330 330 loff_t addr = ebnum * mtd->erasesize; 331 331 332 - ret = mtd->block_isbad(mtd, addr); 332 + ret = mtd_block_isbad(mtd, addr); 333 333 if (ret) 334 334 printk(PRINT_PREF "block %d is bad\n", ebnum); 335 335 return ret;
+1 -1
drivers/mtd/tests/mtd_pagetest.c
··· 469 469 loff_t addr = ebnum * mtd->erasesize; 470 470 int ret; 471 471 472 - ret = mtd->block_isbad(mtd, addr); 472 + ret = mtd_block_isbad(mtd, addr); 473 473 if (ret) 474 474 printk(PRINT_PREF "block %d is bad\n", ebnum); 475 475 return ret;
+1 -1
drivers/mtd/tests/mtd_readtest.c
··· 132 132 loff_t addr = ebnum * mtd->erasesize; 133 133 int ret; 134 134 135 - ret = mtd->block_isbad(mtd, addr); 135 + ret = mtd_block_isbad(mtd, addr); 136 136 if (ret) 137 137 printk(PRINT_PREF "block %d is bad\n", ebnum); 138 138 return ret;
+1 -1
drivers/mtd/tests/mtd_speedtest.c
··· 296 296 loff_t addr = ebnum * mtd->erasesize; 297 297 int ret; 298 298 299 - ret = mtd->block_isbad(mtd, addr); 299 + ret = mtd_block_isbad(mtd, addr); 300 300 if (ret) 301 301 printk(PRINT_PREF "block %d is bad\n", ebnum); 302 302 return ret;
+1 -1
drivers/mtd/tests/mtd_stresstest.c
··· 132 132 loff_t addr = ebnum * mtd->erasesize; 133 133 int ret; 134 134 135 - ret = mtd->block_isbad(mtd, addr); 135 + ret = mtd_block_isbad(mtd, addr); 136 136 if (ret) 137 137 printk(PRINT_PREF "block %d is bad\n", ebnum); 138 138 return ret;
+1 -1
drivers/mtd/tests/mtd_subpagetest.c
··· 344 344 loff_t addr = ebnum * mtd->erasesize; 345 345 int ret; 346 346 347 - ret = mtd->block_isbad(mtd, addr); 347 + ret = mtd_block_isbad(mtd, addr); 348 348 if (ret) 349 349 printk(PRINT_PREF "block %d is bad\n", ebnum); 350 350 return ret;
+1 -2
drivers/mtd/tests/mtd_torturetest.c
··· 292 292 memset(&bad_ebs[0], 0, sizeof(int) * ebcnt); 293 293 if (mtd->block_isbad) { 294 294 for (i = eb; i < eb + ebcnt; i++) { 295 - err = mtd->block_isbad(mtd, 296 - (loff_t)i * mtd->erasesize); 295 + err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize); 297 296 298 297 if (err < 0) { 299 298 printk(PRINT_PREF "block_isbad() returned %d "
+1 -1
drivers/mtd/ubi/io.c
··· 634 634 if (ubi->bad_allowed) { 635 635 int ret; 636 636 637 - ret = mtd->block_isbad(mtd, (loff_t)pnum * ubi->peb_size); 637 + ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size); 638 638 if (ret < 0) 639 639 ubi_err("error %d while checking if PEB %d is bad", 640 640 ret, pnum);
+1 -1
fs/jffs2/scan.c
··· 455 455 if (jffs2_cleanmarker_oob(c)) { 456 456 int ret; 457 457 458 - if (c->mtd->block_isbad(c->mtd, jeb->offset)) 458 + if (mtd_block_isbad(c->mtd, jeb->offset)) 459 459 return BLK_STATE_BADBLOCK; 460 460 461 461 ret = jffs2_check_nand_cleanmarker(c, jeb);
+2 -2
fs/logfs/dev_mtd.c
··· 157 157 return NULL; 158 158 159 159 *ofs = 0; 160 - while (mtd->block_isbad(mtd, *ofs)) { 160 + while (mtd_block_isbad(mtd, *ofs)) { 161 161 *ofs += mtd->erasesize; 162 162 if (*ofs >= mtd->size) 163 163 return NULL; ··· 177 177 return NULL; 178 178 179 179 *ofs = mtd->size - mtd->erasesize; 180 - while (mtd->block_isbad(mtd, *ofs)) { 180 + while (mtd_block_isbad(mtd, *ofs)) { 181 181 *ofs -= mtd->erasesize; 182 182 if (*ofs <= 0) 183 183 return NULL;
+6 -1
include/linux/mtd/mtd.h
··· 210 210 int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); 211 211 int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); 212 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 214 int (*suspend) (struct mtd_info *mtd); 214 215 void (*resume) (struct mtd_info *mtd); 215 216 ··· 220 219 struct backing_dev_info *backing_dev_info; 221 220 222 221 /* Bad block management functions */ 223 - int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); 224 222 int (*block_markbad) (struct mtd_info *mtd, loff_t ofs); 225 223 226 224 struct notifier_block reboot_notifier; /* default mode before reboot */ ··· 404 404 static inline void mtd_resume(struct mtd_info *mtd) 405 405 { 406 406 mtd->resume(mtd); 407 + } 408 + 409 + static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) 410 + { 411 + return mtd->block_isbad(mtd, ofs); 407 412 } 408 413 409 414 static inline struct mtd_info *dev_to_mtd(struct device *dev)