Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp400965pxk; Fri, 11 Sep 2020 09:54:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/J7vpEc/coeo7qdB8fjJ2lTI1VVuCS3Ep9TF8YsywULr0Za9PMzUsGBhJG6zHwFT+DkYy X-Received: by 2002:a17:907:37b:: with SMTP id rs27mr3110142ejb.0.1599843298756; Fri, 11 Sep 2020 09:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599843298; cv=none; d=google.com; s=arc-20160816; b=MU0J3zamNfhBqhu4HFbGgYaPsLMXJO9nWvgeSS09HtgKtqRL7IS2vjrf3ANqVk5b69 TWpuFi/EW83D+HagN9shJgObsh9sWhWY/PnkDLpItsw5tISj1KWr06CeDX+Ir8MyAQEb JZ8xgvakgtJs5R4l2KtPPuVarxZFJu3HEKMOCn05rExdSJPyRp9UnhphX/Cdai5HDTW2 NRJOHR+avmRVldeofQbOIEZCCMVr2Lpwc89bgFZ/Aon/TAFss6YMxC3Tuzv8CI+Ecx0j 0dLRR6LPtqjBcBKsOASzkPc/Lu3cGojaXRmOjpY+iYHyh5IdZePgFaGsdPMGAo46HGl+ DKUQ== 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:date:subject:cc:to:from; bh=6GpI9R9cCHojOg54BD7Ktlqpcusnu/2Dumwmo8Qu2zE=; b=NoeX82mPhLt4WwjGuvMC3YDkuknc1Jfg+809aW7XtrW5Ujq+FDDc9uRTrzJUzasN0L SGi/YK4hjPRwqdX6zay7+dD43WMcrlnwXtUCwhVDF+IywjWV56joTExDIiCdSqayvjm7 sWqAf2+e66nc7kdQpxBa1PkQSxVNQqMMa6ve+ROCq4uYFWIJDz2laUqeNoWK/VnkVkly bXoV9AXcoB3UbMW9vX6v5vHmR7Q8Kh439csU7Bff2z7uFDl0+7e31EDOLHolC5eSP6n4 T7sWHa6cxEQQwNDFmXMutv3PHdrU/03Ew2UvjfFzkniS67GAkSQ/YlVI32H0NuxdGTKD qA+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si1648194ejq.199.2020.09.11.09.54.35; Fri, 11 Sep 2020 09:54:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbgIKQxz (ORCPT + 99 others); Fri, 11 Sep 2020 12:53:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgIKPGO (ORCPT ); Fri, 11 Sep 2020 11:06:14 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8A8C06137F for ; Fri, 11 Sep 2020 07:47:20 -0700 (PDT) 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 Cc: linux-mtd@lists.infradead.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org 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 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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); -- 2.20.1