Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2235127imm; Wed, 3 Oct 2018 00:10:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV60HkcEdjljdV7QWs6ZbsaBwXWKjFkSYyq7++Dtx1EmHti4TGoEGRVFj6KCvefR+4PBXTaS5 X-Received: by 2002:a17:902:3fa5:: with SMTP id a34-v6mr163402pld.244.1538550646408; Wed, 03 Oct 2018 00:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538550646; cv=none; d=google.com; s=arc-20160816; b=HYW/1dxuUhfoUyIiQ1FF65VsXbPySzs2sUroe8Jum1ERCU4gd2Rk27DblS7hQ2+5Wa x0TA7RACHUyEKGbTTxnQgy9R7wBGJT+OTnoJ2TXvXmQUPBts/C5Y10qE6C/aKSd3yi8M FeVpB0tttT5fQoDgoJrigPQIwmtyT2KEvK6Ly6LGBgULHffHwxA4n1QdFKL9Cqzi/CyE 0BjI4GmdxYy/fRjVk4Ss3j3gJqza0yLV5FikKuHZoEPSQiB4wWFbGNYRnZOB+3peX6A0 UprAGIAIG0d9Kdhdhk/qaF9HZ9ZLAHZwFw961XB4fB3e1uwL2V03wJy4SqUmZuRv6C4f jqQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=xjYFfBw3LCJ4zQoOc/1L2lJ1SD8jrX498uaE/4bVEyY=; b=PxZkIX3iej9O6pA2NWTRvhO6OWsXqkFSSxxsW4dhBwmT+mDeU45VVkXoNNqBdtCqhg 59yIwpx5w6KKV/S6IZMcQXzlATn3CI0Kl0iGAnaPWKW/GTznwQa+dJxyh2tIA4wWM4lp Btq71nxX0RqlQgtizEUecJ3HYEmTSYzYamR6CMvgVJyOSo8+uOdZteUaRr24snXFDKFF 7QC7x8howbmoLR/sK/5COqjL0QxfsKtJQdUaY7V5AH2d76xw+lr8a0Zn02PTCgQSDQdO I6AY/LgxKcc/y4kZHVE70XZKgdqrnSfpvkH6oMlRDZSDMoBKxI8R6nvXwRSpUMMh5PL2 efbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si572217plq.316.2018.10.03.00.10.31; Wed, 03 Oct 2018 00:10:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbeJCN5V (ORCPT + 99 others); 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) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 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; > } > > /*