From patchwork Fri Sep 11 14:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 1362475 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=OHNGmFsC; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BnzC15pXSz9ryj for ; Sat, 12 Sep 2020 00:48:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qLqbmV52D/83WZEFnct7x+cPS05tqc7A0dpoPQtWnmo=; b=OHNGmFsCyXT3rypswK1a1RPKM JFbBcJk5DHjxKEbR4xmIF88dXpGKDtqXquSzFjh7Mx/1iupeF7zWtRNLHI6HFo5gMnfuJMkyRsvVV BM/aXLaewdoFzVJFXoVjeWBMDqj//AkrZO9ZYLGwIspZOe6W+3td+T/gL1YPCR/31wnTlUQuTtpWP /bA9Ezbep8EXqEQRookccP0JL7m1uO2ttRaAVsWYWXvhGs0OGG/EzEid0WzcF8nqj0DzMJ2AI2qyu asc9+0rcKQ14TrBrv/ETbe7jctN5LAwFKKhDe2n2kY+KBk6HqkOMZ6VTesEsKKYt5OXpyzhltoRZr cTfiKq9DQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGkKp-0006KH-QU; Fri, 11 Sep 2020 14:47:31 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGkKe-0006Gy-CI for linux-mtd@lists.infradead.org; Fri, 11 Sep 2020 14:47:22 +0000 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGkKU-0006Pu-NW; Fri, 11 Sep 2020 16:47:10 +0200 Received: from mfe by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGkKP-0006nb-3N; Fri, 11 Sep 2020 16:47:05 +0200 From: Marco Felsch To: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sergei.shtylyov@cogentembedded.com, boris.brezillon@collabora.com, michael@walle.cc, j.neuschaefer@gmx.net Subject: [PATCH 1/3] mtd: spi-nor: sst: fix write support for SST_WRITE marked devices Date: Fri, 11 Sep 2020 16:47:01 +0200 Message-Id: <20200911144703.25409-2-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> References: <20200911144703.25409-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_104720_473941_8BB9B121 X-CRM114-Status: GOOD ( 15.17 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The sst write support for devices using the special SST_WRITE routine is broken since commit commit df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API") because the spi_nor_create_write_dirmap() function checks SPINOR_OP_AAI_WP and sst_write_second. These checks are not valid during probe. The check seems also to be broken since the "op->addr.nbytes = 0" causes the devm_spi_mem_dirmap_create() function to return PTR_ERR(-EINVAL) and the probe() function will fail. It seems that the commit only copy'n'pasted the existing logic. Use the correct SST_WRITE flag and return 0 to fix both issues. Fixes: df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API") Signed-off-by: Marco Felsch Reviewed-by: Tudor Ambarus --- drivers/mtd/spi-nor/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 65eff4ce6ab1..31869ac245a8 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3289,15 +3289,21 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor) }; struct spi_mem_op *op = &info.op_tmpl; + /* + * Most SST SPI-NOR's have a special write routine.which should so + * dirmap.wdesc is not supported for these. + */ + if (nor->info->flags & SST_WRITE) { + nor->dirmap.wdesc = NULL; + return 0; + } + /* get transfer protocols. */ op->cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->write_proto); op->addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto); op->dummy.buswidth = op->addr.buswidth; op->data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto); - if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) - op->addr.nbytes = 0; - nor->dirmap.wdesc = devm_spi_mem_dirmap_create(nor->dev, nor->spimem, &info); return PTR_ERR_OR_ZERO(nor->dirmap.wdesc); From patchwork Fri Sep 11 14:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 1362478 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=dlC0HKQ+; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BnzCM45gQz9ryj for ; Sat, 12 Sep 2020 00:48:31 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cRPKjfwYUpo56DSPkluFYerQLnjaOVgO3iFB13Mnmj4=; b=dlC0HKQ+9sAZoXnWayQqgesnB eyEKecxn8lGKuqrnb9iwYppcMcWhjMbs7XfTiX3cL0TjEhyQws4pjfycmxrlvOdSe5idYHLyrv5cg /NbzDmw7GDe7599xbadVyUKrYWzWKh8dhl1mhF7us9fl/BQJbbWYG8WGduKlXcTeL9lv5XT7Lz2zA DGa/2NkpvXqxGIvv9g5V89GduEgqKPAturBrlQJL4oKtHQLaQEoOcsBncqYDvt4+5DxrVPOkt9ZMo BZNM3/aUCaDqNAQP5kAt8JfqP/tmrGVSNHNpXQoiyUB/MC6x/5hmlxPsdtrnoTn0IDTBwJc2ifAx6 9LJZghDng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGkKm-0006JX-Jz; Fri, 11 Sep 2020 14:47:28 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGkKe-0006Gu-5y for linux-mtd@lists.infradead.org; Fri, 11 Sep 2020 14:47:21 +0000 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGkKU-0006Pv-NW; Fri, 11 Sep 2020 16:47:10 +0200 Received: from mfe by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGkKP-0006nd-40; Fri, 11 Sep 2020 16:47:05 +0200 From: Marco Felsch To: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sergei.shtylyov@cogentembedded.com, boris.brezillon@collabora.com, michael@walle.cc, j.neuschaefer@gmx.net Subject: [PATCH 2/3] mtd: spi-nor: sst: add missing write_enable Date: Fri, 11 Sep 2020 16:47:02 +0200 Message-Id: <20200911144703.25409-3-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> References: <20200911144703.25409-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_104720_263531_ED17841C X-CRM114-Status: GOOD ( 15.90 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org According the datasheet [1] the WEL is automatically reset after the Byte-Program instruction completion. So if we program the device with byte-size set to 32 and starting from an odd address only the first and the last byte is written. Fix this by (re-)anble the write support for the first SPINOR_OP_AAI_WP sequence. [1] http://ww1.microchip.com/downloads/en/DeviceDoc/20005044C.pdf; "4.3.2 WRITE ENABLE LATCH (WEL)" Signed-off-by: Marco Felsch --- drivers/mtd/spi-nor/sst.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index e0af6d25d573..644252e27a2a 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -79,6 +79,13 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, /* Write out most of the data here. */ for (; actual < len - 1; actual += 2) { + /* Enable write support if odd address was written before */ + if (actual == 1) { + ret = spi_nor_write_enable(nor); + if (ret) + goto out; + } + nor->program_opcode = SPINOR_OP_AAI_WP; /* write two bytes. */ From patchwork Fri Sep 11 14:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 1362476 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=I8ncPtDo; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BnzC16fYpz9sTN for ; Sat, 12 Sep 2020 00:48:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ITHa8o6SlvSWTAGkFcCL5imoy4IvpVhLpCgEH2NBBJY=; b=I8ncPtDoI8jAotqjsecaqRPia NRhOQ8C7l6T0YIWkM98IIC7yXCtSsFXQ7JUi3DkkFzkJT9dCc8iMfjz01GWjo0hR6Cvc9jpgpsiJG GoWuo44GoftGczDGIoxBy0qJTbSHZnCZsi5F93Hx0U0VitbQc0F0D4KekraWCqKUjkEbmE+qkhkyN H5GRv4E5+uqMdsNwhfDPe2cly25lcpT6Jk2tn5SsowiM1yDkWB309hfz2Q8v+aPYeKTqjXpxE7ylk ACMjwrGRWWO5w/mynuDeJpVFvFXs2d/ya1/QPBBX8qaHe+awiViR54VQtjBfhv3IClzCzwR21HXyI aqynOB4ng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGkKl-0006IT-Fl; Fri, 11 Sep 2020 14:47:27 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGkKe-0006Gt-5x for linux-mtd@lists.infradead.org; Fri, 11 Sep 2020 14:47:21 +0000 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGkKU-0006Pw-NV; Fri, 11 Sep 2020 16:47:10 +0200 Received: from mfe by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGkKP-0006nh-4Z; Fri, 11 Sep 2020 16:47:05 +0200 From: Marco Felsch To: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sergei.shtylyov@cogentembedded.com, boris.brezillon@collabora.com, michael@walle.cc, j.neuschaefer@gmx.net Subject: [PATCH 3/3] mtd: spi-nor: sst: move sst_write_second to local driver Date: Fri, 11 Sep 2020 16:47:03 +0200 Message-Id: <20200911144703.25409-4-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> References: <20200911144703.25409-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_104720_264079_E3084059 X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Don't mess the spi-nor core with details only relating to this specific device. Handle the addr_width locally and drop the sst related stuff from the spi-nor core to clean it up. Signed-off-by: Marco Felsch --- drivers/mtd/spi-nor/core.c | 3 --- drivers/mtd/spi-nor/sst.c | 10 ++++++---- include/linux/mtd/spi-nor.h | 2 -- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 31869ac245a8..fabd8ca4e801 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -173,9 +173,6 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t to, op.addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto); op.data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto); - if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) - op.addr.nbytes = 0; - if (spi_nor_spimem_bounce(nor, &op)) memcpy(nor->bouncebuf, buf, op.data.nbytes); diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index 644252e27a2a..7ca7e1a13511 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -58,10 +58,9 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) goto out; - nor->sst_write_second = false; - /* Start write from odd address. */ if (to % 2) { + nor->addr_width = 3; nor->program_opcode = SPINOR_OP_BP; /* write one byte. */ @@ -86,6 +85,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, goto out; } + /* Send address only once for each AAI_WP cycle */ + nor->addr_width = (actual > 1) ? 0 : 3; nor->program_opcode = SPINOR_OP_AAI_WP; /* write two bytes. */ @@ -97,9 +98,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) goto out; to += 2; - nor->sst_write_second = true; } - nor->sst_write_second = false; ret = spi_nor_write_disable(nor); if (ret) @@ -115,6 +114,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) goto out; + nor->addr_width = 3; nor->program_opcode = SPINOR_OP_BP; ret = spi_nor_write_data(nor, to, 1, buf + actual); if (ret < 0) @@ -129,6 +129,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ret = spi_nor_write_disable(nor); } out: + /* Set to default in case no trailing bytes are written */ + nor->addr_width = 3; *retlen += actual; spi_nor_unlock_and_unprep(nor); return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 60bac2c0ec45..4368c0c41fda 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -343,7 +343,6 @@ struct spi_nor_flash_parameter; * @read_opcode: the read opcode * @read_dummy: the dummy needed by the read operation * @program_opcode: the program opcode - * @sst_write_second: used by the SST write operation * @flags: flag options for the current SPI NOR (SNOR_F_*) * @read_proto: the SPI protocol for read operations * @write_proto: the SPI protocol for write operations @@ -374,7 +373,6 @@ struct spi_nor { enum spi_nor_protocol read_proto; enum spi_nor_protocol write_proto; enum spi_nor_protocol reg_proto; - bool sst_write_second; u32 flags; const struct spi_nor_controller_ops *controller_ops;