mirror of https://gitee.com/openkylin/linux.git
mtd: do not use mtd->block_markbad directly
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>
This commit is contained in:
parent
d58b27ed58
commit
800ffd3496
|
@ -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)))
|
if (copy_from_user(&offs, argp, sizeof(loff_t)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (!mtd->block_markbad)
|
return mtd_block_markbad(mtd, offs);
|
||||||
ret = -EOPNOTSUPP;
|
|
||||||
else
|
|
||||||
return mtd_block_markbad(mtd, offs);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -673,7 +673,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
|
||||||
struct mtd_concat *concat = CONCAT(mtd);
|
struct mtd_concat *concat = CONCAT(mtd);
|
||||||
int i, err = -EINVAL;
|
int i, err = -EINVAL;
|
||||||
|
|
||||||
if (!concat->subdev[0]->block_markbad)
|
if (!mtd_can_have_bb(concat->subdev[0]))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ofs > mtd->size)
|
if (ofs > mtd->size)
|
||||||
|
|
|
@ -199,7 +199,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mtd->block_markbad && ret == -EIO) {
|
if (mtd_can_have_bb(mtd) && 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");
|
||||||
|
|
|
@ -274,7 +274,7 @@ static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb)
|
||||||
eb->root = NULL;
|
eb->root = NULL;
|
||||||
|
|
||||||
/* badblocks not supported */
|
/* badblocks not supported */
|
||||||
if (!d->mtd->block_markbad)
|
if (!mtd_can_have_bb(d->mtd))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
offset = mtdswap_eb_offset(d, eb);
|
offset = mtdswap_eb_offset(d, eb);
|
||||||
|
|
|
@ -1130,9 +1130,6 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *
|
||||||
if( ++jeb->bad_count < MAX_ERASE_FAILURES)
|
if( ++jeb->bad_count < MAX_ERASE_FAILURES)
|
||||||
return 0;
|
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);
|
printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset);
|
||||||
ret = mtd_block_markbad(c->mtd, bad_offset);
|
ret = mtd_block_markbad(c->mtd, bad_offset);
|
||||||
|
|
||||||
|
|
|
@ -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)
|
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);
|
return mtd->block_markbad(mtd, ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue