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

Commit c00a0991 authored by Brian Norris's avatar Brian Norris Committed by David Woodhouse
Browse files

mtd: nand: remove autoincrement 'sndcmd' code



The NAND_NO_AUTOINCR option is always set, so we will kill the option and make
"no autoincrement" the default behavior for nand_base.c. Thus, we should remove
the code which decides whether or not to send the NAND_CMD_READ0 command.
Instead, we unconditionally send the command.

Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 831d316b
Loading
Loading
Loading
Loading
+6 −37
Original line number Original line Diff line number Diff line
@@ -1477,8 +1477,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
	int chipnr, page, realpage, col, bytes, aligned;
	int chipnr, page, realpage, col, bytes, aligned;
	struct nand_chip *chip = mtd->priv;
	struct nand_chip *chip = mtd->priv;
	struct mtd_ecc_stats stats;
	struct mtd_ecc_stats stats;
	int blkcheck = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;
	int sndcmd = 1;
	int ret = 0;
	int ret = 0;
	uint32_t readlen = ops->len;
	uint32_t readlen = ops->len;
	uint32_t oobreadlen = ops->ooblen;
	uint32_t oobreadlen = ops->ooblen;
@@ -1509,10 +1507,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
		if (realpage != chip->pagebuf || oob) {
		if (realpage != chip->pagebuf || oob) {
			bufpoi = aligned ? buf : chip->buffers->databuf;
			bufpoi = aligned ? buf : chip->buffers->databuf;


			if (likely(sndcmd)) {
			chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
			chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
				sndcmd = 0;
			}


			/*
			/*
			 * Now read the page into the buffer.  Absent an error,
			 * Now read the page into the buffer.  Absent an error,
@@ -1564,13 +1559,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
			}
			}


			if (!(chip->options & NAND_NO_READRDY)) {
			if (!(chip->options & NAND_NO_READRDY)) {
				/*
				/* Apply delay or wait for ready/busy pin */
				 * Apply delay or wait for ready/busy pin. Do
				 * this before the AUTOINCR check, so no
				 * problems arise if a chip which does auto
				 * increment is marked as NOAUTOINCR by the
				 * board driver.
				 */
				if (!chip->dev_ready)
				if (!chip->dev_ready)
					udelay(chip->chip_delay);
					udelay(chip->chip_delay);
				else
				else
@@ -1600,13 +1589,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
			chip->select_chip(mtd, -1);
			chip->select_chip(mtd, -1);
			chip->select_chip(mtd, chipnr);
			chip->select_chip(mtd, chipnr);
		}
		}

		/*
		 * Check, if the chip supports auto page increment or if we
		 * have hit a block boundary.
		 */
		if (!NAND_CANAUTOINCR(chip) || !(page & blkcheck))
			sndcmd = 1;
	}
	}


	ops->retlen = ops->len - (size_t) readlen;
	ops->retlen = ops->len - (size_t) readlen;
@@ -1800,10 +1782,9 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
			    struct mtd_oob_ops *ops)
			    struct mtd_oob_ops *ops)
{
{
	int page, realpage, chipnr, sndcmd = 1;
	int page, realpage, chipnr;
	struct nand_chip *chip = mtd->priv;
	struct nand_chip *chip = mtd->priv;
	struct mtd_ecc_stats stats;
	struct mtd_ecc_stats stats;
	int blkcheck = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;
	int readlen = ops->ooblen;
	int readlen = ops->ooblen;
	int len;
	int len;
	uint8_t *buf = ops->oobbuf;
	uint8_t *buf = ops->oobbuf;
@@ -1842,20 +1823,15 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,


	while (1) {
	while (1) {
		if (ops->mode == MTD_OPS_RAW)
		if (ops->mode == MTD_OPS_RAW)
			sndcmd = chip->ecc.read_oob_raw(mtd, chip, page, sndcmd);
			chip->ecc.read_oob_raw(mtd, chip, page, 1);
		else
		else
			sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd);
			chip->ecc.read_oob(mtd, chip, page, 1);


		len = min(len, readlen);
		len = min(len, readlen);
		buf = nand_transfer_oob(chip, buf, ops, len);
		buf = nand_transfer_oob(chip, buf, ops, len);


		if (!(chip->options & NAND_NO_READRDY)) {
		if (!(chip->options & NAND_NO_READRDY)) {
			/*
			/* Apply delay or wait for ready/busy pin */
			 * Apply delay or wait for ready/busy pin. Do this
			 * before the AUTOINCR check, so no problems arise if a
			 * chip which does auto increment is marked as
			 * NOAUTOINCR by the board driver.
			 */
			if (!chip->dev_ready)
			if (!chip->dev_ready)
				udelay(chip->chip_delay);
				udelay(chip->chip_delay);
			else
			else
@@ -1876,13 +1852,6 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
			chip->select_chip(mtd, -1);
			chip->select_chip(mtd, -1);
			chip->select_chip(mtd, chipnr);
			chip->select_chip(mtd, chipnr);
		}
		}

		/*
		 * Check, if the chip supports auto page increment or if we
		 * have hit a block boundary.
		 */
		if (!NAND_CANAUTOINCR(chip) || !(page & blkcheck))
			sndcmd = 1;
	}
	}


	ops->oobretlen = ops->ooblen;
	ops->oobretlen = ops->ooblen;