From patchwork Tue Aug 12 00:59:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 379169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 189F514010C for ; Tue, 12 Aug 2014 11:00:54 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XH0R3-00045E-16; Tue, 12 Aug 2014 00:59:33 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XH0R1-00040v-B6 for linux-mtd@lists.infradead.org; Tue, 12 Aug 2014 00:59:31 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 11 Aug 2014 17:59:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,845,1400050800"; d="scan'208";a="575290988" Received: from shldeisgchi005.sh.intel.com ([10.239.67.142]) by fmsmga001.fm.intel.com with ESMTP; 11 Aug 2014 17:59:09 -0700 Date: Tue, 12 Aug 2014 08:59:12 +0800 From: Huang Shijie To: Brian Norris Subject: Re: [PATCH 7/8] mtd: spi-nor: factor out write_enable() for erase commands Message-ID: <20140812005912.GA1850@shldeISGChi005.sh.intel.com> References: <1407374222-8448-1-git-send-email-computersforpeace@gmail.com> <1407374222-8448-8-git-send-email-computersforpeace@gmail.com> <20140809105232.GA1571@localhost.localdomain> <20140811184818.GY3711@ld-irv-0074> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140811184818.GY3711@ld-irv-0074> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140811_175931_406137_6B17BE6F X-CRM114-Status: GOOD ( 21.36 ) X-Spam-Score: -6.3 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [192.55.52.93 listed in wl.mailspike.net] Cc: Marek Vasut , Huang Shijie , zajec5@gmail.com, Huang Shijie , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Mon, Aug 11, 2014 at 11:48:18AM -0700, Brian Norris wrote: > On Sat, Aug 09, 2014 at 06:52:34PM +0800, Huang Shijie wrote: > > On Wed, Aug 06, 2014 at 06:17:01PM -0700, Brian Norris wrote: > > > write_enable() was being duplicated to both m25p80.c and fsl-quadspi.c. > > > But this should be handled within the spi-nor abstraction layer. > > > > > > At the same time, let's add write_disable() after erasing, so we don't > > > leave the flash in a write-enabled state afterward. > > > > > > Signed-off-by: Brian Norris > > > --- > > > drivers/mtd/devices/m25p80.c | 5 ----- > > > drivers/mtd/spi-nor/fsl-quadspi.c | 5 ----- > > > drivers/mtd/spi-nor/spi-nor.c | 7 ++++--- > > > 3 files changed, 4 insertions(+), 13 deletions(-) > > > > > > diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c > > > index 96226ea69f90..116d979ffdb9 100644 > > > --- a/drivers/mtd/devices/m25p80.c > > > +++ b/drivers/mtd/devices/m25p80.c > > > @@ -158,11 +158,6 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset) > > > dev_dbg(nor->dev, "%dKiB at 0x%08x\n", > > > flash->mtd.erasesize / 1024, (u32)offset); > > > > > > - /* Send write enable, then erase commands. */ > > > - ret = nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0); > > > - if (ret) > > > - return ret; > > > - > > > /* Set up command buffer. */ > > > flash->command[0] = nor->erase_opcode; > > > m25p_addr2cmd(nor, offset, flash->command); > > > diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c > > > index 9c13622a0c7a..07fbfb0a7738 100644 > > > --- a/drivers/mtd/spi-nor/fsl-quadspi.c > > > +++ b/drivers/mtd/spi-nor/fsl-quadspi.c > > > @@ -738,11 +738,6 @@ static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs) > > > dev_dbg(nor->dev, "%dKiB at 0x%08x:0x%08x\n", > > > nor->mtd->erasesize / 1024, q->chip_base_addr, (u32)offs); > > > > > > - /* Send write enable, then erase commands. */ > > > - ret = nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0); > > > - if (ret) > > > - return ret; > > > - > > This write-enable is used for per-sector-erase, not for the whole chip > > erase. > > > > So if you really want to remove this code, you should add an extra write-enable > > in the spi_nor_erase. > > I don't understand your comment. > > Before this patch, there is a write-enable command in: > * m25p80.c, per-sector erase > * fsl-quadspi, per-sector erase > * spi-nor.c, whole-chip erase > > With this patch, I am factoring all of these out into spi_nor_erase(). > > What is the problem? Hi Brian: For the spi_nor_erase(), the patch should like this: thanks Huang Shijie diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index c130bf7..26c48bc 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -324,6 +324,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) /* whole-chip erase? */ if (len == mtd->size) { + write_enable(nor); if (erase_chip(nor)) { ret = -EIO; goto erase_err; @@ -337,6 +338,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) /* "sector"-at-a-time erase */ } else { while (len) { + write_enable(nor); if (nor->erase(nor, addr)) { ret = -EIO; goto erase_err;