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

Commit 01039e4e authored by Roman Tereshonkov's avatar Roman Tereshonkov Committed by David Woodhouse
Browse files

mtd: onenand: bugfix for 2x mode bad block handling



This bug becomes visible in 2x mode when chip->writesize
is different from mtd->writesize (= 2 * chip->writesize).
At this case the bad block information is read from
the first and the third physical pages instead of
the first and the second as specification states.

Signed-off-by: default avatarRoman Tereshonkov <roman.tereshonkov@nokia.com>
Acked-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 8a8f632d
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -91,13 +91,15 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
		for (j = 0; j < len; j++) {
		for (j = 0; j < len; j++) {
			/* No need to read pages fully,
			/* No need to read pages fully,
			 * just read required OOB bytes */
			 * just read required OOB bytes */
			ret = onenand_bbt_read_oob(mtd, from + j * mtd->writesize + bd->offs, &ops);
			ret = onenand_bbt_read_oob(mtd,
				from + j * this->writesize + bd->offs, &ops);


			/* If it is a initial bad block, just ignore it */
			/* If it is a initial bad block, just ignore it */
			if (ret == ONENAND_BBT_READ_FATAL_ERROR)
			if (ret == ONENAND_BBT_READ_FATAL_ERROR)
				return -EIO;
				return -EIO;


			if (ret || check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
			if (ret || check_short_pattern(&buf[j * scanlen],
					       scanlen, this->writesize, bd)) {
				bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
				bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
				printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
				printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
					i >> 1, (unsigned int) from);
					i >> 1, (unsigned int) from);