Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f461a73 authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse
Browse files

mtd: introduce mtd_can_have_bb helper



This patch introduces new 'mtd_can_have_bb()' helper function which checks
whether the flash can have bad eraseblocks. Then it changes all the
direct 'mtd->block_isbad' use cases with 'mtd_can_have_bb()'.

Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 079c985e
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -867,9 +867,6 @@ 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_isbad)
			ret = -EOPNOTSUPP;
		else
		return mtd_block_isbad(mtd, offs);
		break;
	}
+1 −1
Original line number Diff line number Diff line
@@ -647,7 +647,7 @@ static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs)
	struct mtd_concat *concat = CONCAT(mtd);
	int i, res = 0;

	if (!concat->subdev[0]->block_isbad)
	if (!mtd_can_have_bb(concat->subdev[0]))
		return res;

	if (ofs > mtd->size)
+2 −2
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
			cxt->nextpage = 0;
	}

	while (mtd->block_isbad) {
	while (mtd_can_have_bb(mtd)) {
		ret = mtd_block_isbad(mtd, cxt->nextpage * record_size);
		if (!ret)
			break;
@@ -257,7 +257,7 @@ static void find_next_position(struct mtdoops_context *cxt)
	size_t retlen;

	for (page = 0; page < cxt->oops_pages; page++) {
		if (mtd->block_isbad &&
		if (mtd_can_have_bb(mtd) &&
		    mtd_block_isbad(mtd, page * record_size))
			continue;
		/* Assume the page is used */
+2 −2
Original line number Diff line number Diff line
@@ -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 && mtd_block_isbad(d->mtd, offset))
	if (mtd_can_have_bb(d->mtd) && mtd_block_isbad(d->mtd, offset))
		return MTDSWAP_SCANNED_BAD;

	ops.ooblen = 2 * d->mtd->ecclayout->oobavail;
@@ -1058,7 +1058,7 @@ static unsigned int mtdswap_badblocks(struct mtd_info *mtd, uint64_t size)

	badcnt = 0;

	if (mtd->block_isbad)
	if (mtd_can_have_bb(mtd))
		for (offset = 0; offset < size; offset += mtd->erasesize)
			if (mtd_block_isbad(mtd, offset))
				badcnt++;
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
	if (memcmp(mtd->name, "DiskOnChip", 10))
		return;

	if (!mtd->block_isbad) {
	if (!mtd_can_have_bb(mtd)) {
		printk(KERN_ERR
"NFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n"
"Please use the new diskonchip driver under the NAND subsystem.\n");
Loading