From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23B47C64EBC for ; Wed, 3 Oct 2018 07:10:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7CAE20684 for ; Wed, 3 Oct 2018 07:10:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7CAE20684 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727151AbeJCN5V (ORCPT ); Wed, 3 Oct 2018 09:57:21 -0400 Received: from mail.bootlin.com ([62.4.15.54]:55495 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbeJCN5U (ORCPT ); Wed, 3 Oct 2018 09:57:20 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 8ED15207CC; Wed, 3 Oct 2018 09:10:13 +0200 (CEST) Received: from bbrezillon (AAubervilliers-681-1-24-95.w90-88.abo.wanadoo.fr [90.88.144.95]) by mail.bootlin.com (Postfix) with ESMTPSA id 38D3A206A2; Wed, 3 Oct 2018 09:10:03 +0200 (CEST) Date: Wed, 3 Oct 2018 09:10:03 +0200 From: Boris Brezillon To: Yogesh Gaur Cc: linux-mtd@lists.infradead.org, frieder.schrempf@exceet.de, computersforpeace@gmail.com, david.wolfe@nxp.com, han.xu@nxp.com, festevam@gmail.com, marek.vasut@gmail.com, prabhakar.kushwaha@nxp.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: devices: m25p80: Make sure WRITE_EN is issued before each write Message-ID: <20181003091003.5fb134e1@bbrezillon> In-Reply-To: <1528870158-14781-1-git-send-email-yogeshnarayan.gaur@nxp.com> References: <1528870158-14781-1-git-send-email-yogeshnarayan.gaur@nxp.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jun 2018 11:39:18 +0530 Yogesh Gaur wrote: > Some SPI controllers can't write nor->page_size bytes in a single step > because their TX FIFO is too small, but when that happens we should > make sure a WRITE_EN command before each write access and READ_SR command > after each write access is issued. > > The core is already taking care of that, so all we have to do here is > return the actual number of bytes that were written during the > spi_mem_exec_op() operation. > > Signed-off-by: Yogesh Gaur Queued to spi-nor/next. Thanks, Boris > --- > drivers/mtd/devices/m25p80.c | 23 ++++++++--------------- > 1 file changed, 8 insertions(+), 15 deletions(-) > > diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c > index e84563d..60224fe 100644 > --- a/drivers/mtd/devices/m25p80.c > +++ b/drivers/mtd/devices/m25p80.c > @@ -72,7 +72,6 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len, > SPI_MEM_OP_ADDR(nor->addr_width, to, 1), > SPI_MEM_OP_DUMMY(0, 1), > SPI_MEM_OP_DATA_OUT(len, buf, 1)); > - size_t remaining = len; > int ret; > > /* get transfer protocols. */ > @@ -84,22 +83,16 @@ static ssize_t m25p80_write(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(flash->spimem, &op); > - if (ret) > - return ret; > - > - ret = spi_mem_exec_op(flash->spimem, &op); > - if (ret) > - return ret; > + ret = spi_mem_adjust_op_size(flash->spimem, &op); > + if (ret) > + return ret; > + op.data.nbytes = len < op.data.nbytes ? len : op.data.nbytes; > > - op.addr.val += op.data.nbytes; > - remaining -= op.data.nbytes; > - op.data.buf.out += op.data.nbytes; > - } > + ret = spi_mem_exec_op(flash->spimem, &op); > + if (ret) > + return ret; > > - return len; > + return op.data.nbytes; > } > > /*