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

Commit 555a56b8 authored by Tatyana Brokhman's avatar Tatyana Brokhman
Browse files

mtd: msm_qpic_nand: Support for multi page read



Unsorted Block Images (UBI) driver request multi page read. Currently,
the driver doesn't support handling multi page read in such cases as
the dma mapping might fail. Fix this by splitting the request into
multiple read requests.

Change-Id: Ie31ade385556b09caa7a563c42a8c2b6808e0264
Signed-off-by: default avatarTatyana Brokhman <tlinder@codeaurora.org>
parent 5cc57e3e
Loading
Loading
Loading
Loading
+34 −7
Original line number Original line Diff line number Diff line
@@ -1828,19 +1828,46 @@ static int msm_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
	struct mtd_oob_ops ops;
	struct mtd_oob_ops ops;


	ops.mode = MTD_OPS_AUTO_OOB;
	ops.mode = MTD_OPS_AUTO_OOB;
	ops.len = len;
	ops.retlen = 0;
	ops.retlen = 0;
	ops.ooblen = 0;
	ops.ooblen = 0;
	ops.datbuf = buf;
	ops.oobbuf = NULL;
	ops.oobbuf = NULL;


	if (!(from & (mtd->writesize - 1)) && !(len % mtd->writesize))
	if (!(from & (mtd->writesize - 1)) && !(len % mtd->writesize)) {
		/* read pages on page boundary */
		/*
		 * Handle reading of large size read buffer in vmalloc
		 * address space that does not fit in an MMU page.
		 */
		if (!virt_addr_valid(buf) &&
		   ((unsigned long) buf & ~PAGE_MASK) + len > PAGE_SIZE) {
			ops.len = mtd->writesize;

			for (;;) {
				ops.datbuf = buf;
				ret = msm_nand_read_oob(mtd, from, &ops);
				ret = msm_nand_read_oob(mtd, from, &ops);
	else
				if (ret < 0)
		ret = msm_nand_read_partial_page(mtd, from, &ops);
					break;

				len -= mtd->writesize;
				*retlen += mtd->writesize;
				if (len == 0)
					break;


				buf += mtd->writesize;
				from += mtd->writesize;
			}
		} else {
			ops.len = len;
			ops.datbuf = buf;
			ret =  msm_nand_read_oob(mtd, from, &ops);
			*retlen = ops.retlen;
			*retlen = ops.retlen;
		}
	} else {
		ops.len = len;
		ops.datbuf = buf;
		ret = msm_nand_read_partial_page(mtd, from, &ops);
		*retlen = ops.retlen;
	}

	return ret;
	return ret;
}
}