From patchwork Wed Oct 3 14:40:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 978398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.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=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="H6In3ytk"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="im1LsmLh"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42QKdj6m4Zz9s7W for ; Thu, 4 Oct 2018 01:27:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=V7tiBumIgL3q9TlFObQlkxRkOrAxo1fghvZAzgVWgi4=; b=H6In3ytk1sqLpDnym2c1Jbk1DK H75x3YZAt8gOAHCDazSGqDQxujUcqCK5CdmabrS3Ep7su+480lcnNCYfC7991kC45yv7RPz+MQEv4 bC6g/8/oUhHB3Kzngaf0m1sqcUYgbhpESA7nnr1+EpkKV9TBtdynzPyrGKvWppBTa2r5VgHd9jFF5 VF2lJ4eJDb07yxzqVc/Kkt7dJ0TFs/bckXkQzI+BaTKWgrqqEuyGr+wXz8vLuqWwM+CrvjgpmH7y3 851qRILB+Lu9pq0AETYlZuI+6NwNg3WMC+Ybzq+bB1f7xYfRibzjfOcAaTzOmDKJgnGou8sZUsKV9 tMS3VUbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7j3b-0005KN-Vq; Wed, 03 Oct 2018 15:27:24 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7j2b-0004qU-Sd for linux-mtd@bombadil.infradead.org; Wed, 03 Oct 2018 15:26:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F/JbMOtomOVWzdnIk1A8PUQuXAoQOqXwnG1QXwygMy0=; b=im1LsmLhVQApn+B8S7NMnmge5 9lZho2GP/8DwFCeufDeGjF4sfWJvxU1Kx99h1/0v8naTFd8krc/7K8O0FNVv20Al4xFDY/U4ra8zt iK1SUxjCjKiHUK2fyC5t6dOE+bn99GRq+yfl4H4RWM1J/jZYzuphqa6jzeaP9mNFN2L5WDogQWQDU QgXiA5MwqHh9StnmQHlPr6/IVZs6w6R8+fdaQ7u848Zcs+ex6REMN0kqSqO3v6KSZLQky2yiQkvcG 4JgfyAYDLZjzEIIH/W7e6M4Kt2vuYaVCYI3A2kSkmGbdc2cUO5pfZDRjQa66LDr0ov+LV7C+Tqmef 4TSFkNP5w==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7iKr-0002Td-AC for linux-mtd@lists.infradead.org; Wed, 03 Oct 2018 14:41:10 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 2659D207BB; Wed, 3 Oct 2018 16:40:46 +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, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon.fritz.box (AAubervilliers-681-1-24-95.w90-88.abo.wanadoo.fr [90.88.144.95]) by mail.bootlin.com (Postfix) with ESMTPSA id CFA4C20733; Wed, 3 Oct 2018 16:40:45 +0200 (CEST) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH 8/8] mtd: spi-nor: Move Spansion erase related fixup to a dedicated function Date: Wed, 3 Oct 2018 16:40:43 +0200 Message-Id: <20181003144043.21529-9-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20181003144043.21529-1-boris.brezillon@bootlin.com> References: <20181003144043.21529-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_104109_745156_31255C10 X-CRM114-Status: GOOD ( 12.21 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [62.4.15.54 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Su , Cyrille Pitchen , Mason Yang , Tudor Ambarus , zhengxunli@mxic.com.tw MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org spi_nor_set_4byte_opcodes() is changing the erase size for Spansion chips operating in 4B addressing mode. Let's move this code to spansion_fixups() and call it from spi_nor_manufacturer_fixups(). Signed-off-by: Boris Brezillon --- drivers/mtd/spi-nor/spi-nor.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index f2e00755813d..1a9b3e6a181d 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -244,18 +244,6 @@ static u8 spi_nor_convert_3to4_erase(u8 opcode) static void spi_nor_set_4byte_opcodes(struct spi_nor *nor, const struct flash_info *info) { - /* Do some manufacturer fixups first */ - switch (JEDEC_MFR(info)) { - case SNOR_MFR_SPANSION: - /* No small sector erase for 4-byte command set */ - nor->erase_opcode = SPINOR_OP_SE; - nor->mtd.erasesize = info->sector_size; - break; - - default: - break; - } - nor->read_opcode = spi_nor_convert_3to4_read(nor->read_opcode); nor->program_opcode = spi_nor_convert_3to4_program(nor->program_opcode); nor->erase_opcode = spi_nor_convert_3to4_erase(nor->erase_opcode); @@ -3608,6 +3596,15 @@ static void winbond_fixups(struct spi_nor *nor) nor->set_4byte = winbond_set_4byte; } +static void spansion_fixups(struct spi_nor *nor) +{ + if (nor->flags & SPI_NOR_4B_OPCODES) { + /* No small sector erase for 4-byte command set */ + nor->erase_opcode = SPINOR_OP_SE_4B; + nor->mtd.erasesize = nor->info->sector_size; + } +} + static void spi_nor_manufacturer_fixups(struct spi_nor *nor) { switch (JEDEC_MFR(nor->info)) { @@ -3623,6 +3620,10 @@ static void spi_nor_manufacturer_fixups(struct spi_nor *nor) winbond_fixups(nor); break; + case SNOR_MFR_SPANSION: + spansion_fixups(nor); + break; + default: break; }