From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vignesh Raghavendra Date: Wed, 17 Apr 2019 18:17:37 +0530 Subject: [U-Boot] [PATCH v2] mtd: spi: Improve spi_nor_write_data() implementation In-Reply-To: <20190416123126.9416-1-rajat.srivastava@nxp.com> References: <20190416123126.9416-1-rajat.srivastava@nxp.com> Message-ID: <70e227a1-c30b-d24e-187a-ff166578da47@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 16/04/19 5:29 PM, Rajat Srivastava wrote: > Maximum write size in a single write operation in > spi_nor_write_data() function can be equal to slave > tx buffer, which is adjusted in spi_mem_adjust_op_size() > and write operation gets fragmented. > > Previously data write for the above fragmentation > didn't incorporate write enable and status checks. > It was sent to flash at page offsets only. > > Signed-off-by: Rajat Srivastava > --- > Changes in v2: > Incorporating review comments given by Vignesh. > [PATCH v1]: https://patchwork.ozlabs.org/patch/1078183/ Changes look good as such, but I cannot seem to apply these patch locally as mbox for testing. Looking at mail source, it seems to be sent in binary format instead of plain text. Could you resend in plain text? > > drivers/mtd/spi/spi-nor-core.c | 28 ++++++++++------------------ > 1 file changed, 10 insertions(+), 18 deletions(-) > > diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c > index c4e2f6a08f..8e754d445d 100644 > --- a/drivers/mtd/spi/spi-nor-core.c > +++ b/drivers/mtd/spi/spi-nor-core.c > @@ -116,7 +116,6 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, > SPI_MEM_OP_ADDR(nor->addr_width, to, 1), > SPI_MEM_OP_NO_DUMMY, > SPI_MEM_OP_DATA_OUT(len, buf, 1)); > - size_t remaining = len; > int ret; > > /* get transfer protocols. */ > @@ -127,22 +126,19 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, > if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) > op.addr.nbytes = 0; > > - while (remaining) { > - op.data.nbytes = remaining < UINT_MAX ? remaining : UINT_MAX; > - ret = spi_mem_adjust_op_size(nor->spi, &op); > - if (ret) > - return ret; > + op.data.nbytes = len < UINT_MAX ? len : UINT_MAX; > + ret = spi_mem_adjust_op_size(nor->spi, &op); > + if (ret) > + return ret; > > - ret = spi_mem_exec_op(nor->spi, &op); > - if (ret) > - return ret; > + ret = spi_mem_exec_op(nor->spi, &op); > + if (ret) > + return ret; > > - op.addr.val += op.data.nbytes; > - remaining -= op.data.nbytes; > - op.data.buf.out += op.data.nbytes; > - } > + op.addr.val += op.data.nbytes; > + op.data.buf.out += op.data.nbytes; > > - return len; > + return op.data.nbytes; > } > > /* > @@ -1101,10 +1097,6 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, > goto write_err; > *retlen += written; > i += written; > - if (written != page_remain) { > - ret = -EIO; > - goto write_err; > - } > } > > write_err: >