From patchwork Tue Sep 17 15:54:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F87016B1 for ; Tue, 17 Sep 2019 15:57:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C26A214AF for ; Tue, 17 Sep 2019 15:57:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fU2dkLyh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="A2ygFBxk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C26A214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=26TMPIBmnBBYnvgWv77xoG4kOaqDZB1Nn32SJ8xUbbw=; b=fU2dkLyhZIp2ih oWDWU8tQl8EjLlBEqUJH7g4ZEQArehQLR6xZhtIyQfeLhFAZtbvcyKP+wK4PWjKwSFhRxdwuvgv+b xUuACLxDwtC45W9QpdRv1XX+GRrI0BdU18ppwn1K2mXXfP6WH/DXKuAR7So+u7lbvCL7Y2WuuwpQZ +R3Of0Sv8lo7UuWhlVmoVHLZ8radoaahrZTi+4TB8UKjII5XJEPMFTLSgh5Wr02ns5Igwia3JrDx7 yijpXlahmJhD2mVHulZI00+wqM4Jf2dXQPClI3SnAX5Je5mnVs6UBdfN7ONoZ2ZoJSCss46Mi5OlJ dbpr9cwFPwyodruPCgog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFqu-0000Nh-IC; Tue, 17 Sep 2019 15:57:16 +0000 Received: from esa3.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFof-0006Qg-P6; Tue, 17 Sep 2019 15:54:59 +0000 Received-SPF: Pass (esa3.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa3.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa3.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: pd4p5YoAICsj1LHhDqwIvCbShaXWdeuV9/cvkVzCZZ/Wd8WwlIajEVa8FtFaQLBZQTyv2IRImg PJLTzbWDMMEEDaAlDKxT/kPu9+AK1ySWFHJZke1yDvtih8PoKFc0llSui6b8ALNRjS371y4mvv DSZnND9YR89pLe041LBGzsxaSAsNp8n1ATrg9ogVqSyzkZBLpEGvAE8oM5FKnpm1hx8aK17UoV lw4fkYKCjq7KHbuIIHI5GGKjTWd/efQDPkpFOJwGiQU+QJW6irpOOF4uQbXOVdomneBtMhijXw qyU= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="49417037" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:54:55 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:54:45 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:54:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fOOMw5ylFtAAZh4kd2JmXhcIB7PQUgs7GbLtHdnzZo+lr7jwup2z4WU1wS1jymsrnGwTVAIxisKOXQQgUeZ242a+QOPreCKYTS+1OFgWpv39UILPW7vhfdZq/qStyQIQlHrl8y/oO7DA5gVDpe9g5GXVYETxg1EL1bU/5HfolsxK2rS33HyUfoZ9ecPS/chykLSn3vRt2ZYZFkoR9/kPIqVipgFizAjWs2rPEt1UlZJT4R2gO22Q2PI7ng8NAEGOIFLwGt3332cPWhqCCvC33PuSfiC/TnykLx4gHOdSHuUZUkJlGlEtGhEHz23NNk3PCcU822cRh/Thg64Hkq12FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IX7QLQOz/p1Yx0WDeQlhyU6NDR1qB0ng5ZogcAsBO6w=; b=BoUVYmKRisSalpZu16ILf8khaKe92GvhBO5NCML6M7JQbPX++gmwNsVQ1QVVvC7and65ITJmq84pRDY1rcwqWYhdILNBbzyLwiI4TT8fzHE6yNNVCxx4nzHTCRvXn86evm5WYt2mq9H7K3YEpjo2VVi5TuvJXjPvZqyJ9Pf3Wnm9CsPncdBB/VElx9wL6cgazX8/xSC7ov+vAzhavd1OVYo3iBd3c/BRxZzyWW0E5byLiNVo7pmJ/OeWzGCEfMm8I4lQM6Y/mXlwvwuudFzJBvzatt0exGGvZOrS6mE41kP7tC19pgdwlB4TWkMza0xsRtohzvgT/XiaEFZk3DOexw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IX7QLQOz/p1Yx0WDeQlhyU6NDR1qB0ng5ZogcAsBO6w=; b=A2ygFBxkjr5/Xiiq95JzcZpNnxpfXXYT0gZ4KoAZzF76Irl/f8BB97n9iHA52DA4gq753N2y7fsrsmuyKSryhsqPkIkbMtmYEDA6WeFq4Be2jjA3xmF37vsMcFjeMvND2T65/vhYJI3LGkKQmgwrU8xcA6cYdy/B5HUhpzsay1U= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:54:44 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:54:44 +0000 From: To: , , , , , Subject: [PATCH 01/23] mtd: spi-nor: hisi-sfc: Drop nor->erase NULL assignment Thread-Topic: [PATCH 01/23] mtd: spi-nor: hisi-sfc: Drop nor->erase NULL assignment Thread-Index: AQHVbXA5Ho5yneiBdU61SqVbpzgJYA== Date: Tue, 17 Sep 2019 15:54:43 +0000 Message-ID: <20190917155426.7432-2-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 079e1b6a-1568-45aa-b203-08d73b875b61 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001)(4744005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ExlxoHL7/qlbiTzSx/k4J9FUTRePNdcGc5OxNqLlu3msxE83TTApIziMh8R3tF5UAifMbZPWdXvY0QncItqwFC51te3LbWuNjGJ7OXyQaaTcAFkGhpKjdG06tHbcIRwDlmR+73gQLbSuGROWoA/Jx3E88zQDQZXFBaZ8lUGznZUbXRTVck5Q1tSNmGqj99etcm5KVVpdyZqRqTECcUkHxe635XBfn/Rmbrfj1ny6+BXjlP7G1bCbjJwLFt8KPhmmH4Vc53xYpgZJQsk5TCphsEeX5Rfd0uofIFqhxe0dGJeGN2CPJDe4MgNXoYUqvUmP4gcXRwuPpFZFwFf76uh+W4z0kKuuzYBdBGulqH36tlCaotuo4/TaojOdOeK9BNPiFfQIuhbLp3rdAQsTrynzdB5Dxm7t0CRnERhcIeCnTh0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 079e1b6a-1568-45aa-b203-08d73b875b61 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:54:44.0724 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Kw52zqPhl5/2wltx/ihGOylsIRmlU/sk46VPfzTmGEzaMF9huQdAAqKTM4Q51DM8ApQAqLLX4mfRPxrPNw051OTh0c82i3DRD2Hmvuz/XS8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085457_835681_93C4B44D X-CRM114-Status: UNSURE ( 6.87 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.153.233 listed in list.dnswl.org] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus The pointer to 'struct spi_nor' is kzalloc'ed above in the code. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/hisi-sfc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c index 6dac9dd8bf42..c99ed9cdbf9c 100644 --- a/drivers/mtd/spi-nor/hisi-sfc.c +++ b/drivers/mtd/spi-nor/hisi-sfc.c @@ -364,7 +364,6 @@ static int hisi_spi_nor_register(struct device_node *np, nor->write_reg = hisi_spi_nor_write_reg; nor->read = hisi_spi_nor_read; nor->write = hisi_spi_nor_write; - nor->erase = NULL; ret = spi_nor_scan(nor, NULL, &hwcaps); if (ret) return ret; From patchwork Tue Sep 17 15:54:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86D63912 for ; Tue, 17 Sep 2019 16:01:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5CB85214AF for ; Tue, 17 Sep 2019 16:01:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LZcUuJbV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="tcC/Lk1b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CB85214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=QM/ef1W1fjBI/I/RF8FyCIlQ5qefHhx+dSocvRmGRR0=; b=LZcUuJbVkngvyd Olt3CIgaQmleh2e5CJA6AxmUx2iFNvOh7HJJSRTlYSj/GybQMTgXSFsFfd9WeoxbtTWtTpDYWkVgg Er2tGfDMlqs7g6u4/oXIL9adtRDQnCkCv7Hi0JaMUCBrgtsCzuomPt8O7vVsrnJl8oRhoZwc2S8hp 3Y7oYtbuq7XXHvpA/FTjTZOQk9u6Ek4soY4fuYlT2FahVpwUCrjn4vrB/JOINvcSvWFE2HE+9s9Lu blPCGSeUhEnoNpGM0WExuBv0c6JuWb36V3w1ISk24t2W0/aimcnWQYEJArvH7p9MWGHC/DR+c/svw DcUo0K9eBPoOoufkEiqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFuV-0004os-I3; Tue, 17 Sep 2019 16:00:59 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFot-0007bC-Ph; Tue, 17 Sep 2019 15:55:16 +0000 Received-SPF: Pass (esa4.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa4.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa4.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: LNxLS6OulxgRW3JiWtrRflI2Z+nragxcSAoB77SYuO5+DNeFT+f3NM/41YIVGqHUFRy+oATGvB p8Gy2Qkzx9AFfXVYchInJHABkuZYzavwvodD4U5MZNORSlUqZB0viFYf2vLThXkcLA0wb5qGPu 6KiBQ9dMl1N7KxRJzdCm5xMu7yT3LYlKrLUUIcIZ72pj7U7dM6V2oJCMmuH1u7uGQV0D4dbQZS /vWoL55Pro7q0C3V1/PZ1lICcZ4Gsy+hTANd1ba5nQNM3ZAcomIrjKf+cLg65PiXBB+e/0RVtn vjY= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="48252396" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:04 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:54:50 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:54:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZRkcwNPjNLwNm8fGYPU7mvF2CxL+vE7HpDFPbbCSiXLfDHyD+V5vyHGXMmOUl0TuP00htkknCjdDd3JeH4phO0iCHNC0CKHvFp4VC7v0xVRqzKW5RjHfQR9kLx1aTb5XLO0YQTdxTtKlx1OEeC5fm080JuHsCJN65W2kPdsC3kSux9kbDuxGGhpmEfQeMZA/vTvBSGkdl/YJa3Uf7CrXHZXEo2B1boc0ramdhhqdNMqbyJX1PBlVFjHJRufSDWc8Ak4Ob44uHwpGOtRzSbpuSegyZIrAxUaOxHZFw6k0XBAOeSnObJ8zQJVGfqJR/kJWxOp39jNJ2V4FQ5RYFOJNIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NYSuV3rNSK2cyD0B8kBJl5bzSvj8OrKoGlU8G+Pysuk=; b=lF64cLY+emsH6Ws3jk96Lx/PhUDDyFA/ON6U1eThXcwXdmGNGjdNqBCW64OTdGH9Ytz0/Q7TGjs1kJL6naYgIWyg4lqgvrRgFJ/ehqE+1sh0/bukgARtpj0m94mdrwkoHy4eNOKuMAeORJwE9BAuLTaHtYVNN9rWLe2liTvK8t0v7kAhVZmNXggq985dBtc97gOjhWBF0zfEgyucbMOQ2l6crI+7oH6pb9o/LRtpWn+6bVRGnoVbbHwatlPXuGrwLQV5PpTkZQAFqfbwZ2M8VC9H2EoNxN5qrhYi4dh3dDqAMOWW3uok8kbTXwIGh4Wrb0/GR/bInUMBRBML318U1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NYSuV3rNSK2cyD0B8kBJl5bzSvj8OrKoGlU8G+Pysuk=; b=tcC/Lk1bdSt/T+l51DY7rxyXQzvwWpeNULeJFPPoK9b5DtrBqQLIhEuWcx84UT7pKi4Fkr1dWUhAFgukHw9JLhNF+QREXGwMTOaDMtEf+LNuC6U0aBbgAtlZdNRll2dD21iVUerfBkOVsDsV2oYb5sX4gmuAUmVQsp+PoafROuE= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:54:47 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:54:47 +0000 From: To: , , , , , Subject: [PATCH 02/23] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops' Thread-Topic: [PATCH 02/23] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops' Thread-Index: AQHVbXA7VfKVpMUx1UqOLh4+dBdplg== Date: Tue, 17 Sep 2019 15:54:47 +0000 Message-ID: <20190917155426.7432-3-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f7764ee2-1571-4d73-76ab-08d73b875d63 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(30864003)(2906002)(446003)(52116002)(2201001)(579004)(559001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: MOnpv1QbMDAmqivoGtXLUcNVYtyH283pFL2TQ5KKcWSZBjhoSZL4T3c1vLSkKEh5N/t5mKaQ6yguOqrrn/xSL1hMh3/L4Vxk9jhQrAIPawuSSpAnIlYHf4kkBtHDYRwloi71MIwHQf7BLmgDntvDw6lExX9SQAC+jbZVDYLMtptDsveuH99Ja1ujXIBR04hg4G9NdB2CrMPuFqmG4cOlrSQc+LSKACm0Ab9wnZaMbvCbOgTSdvEeFszcr8TFoAFSVkCr8Akq88vgeJ/M4KVnDLU4upDnHL6Zn9KEgx6JtpoCzz8eli5/5V8aSTLiL8MSBuhGw23zdNZQbwqyDWKbWNTYPqKjG8I40dlFLEYexpVy/MejbTmnVIMhEB6tFjlJcS/Riml5ZZmOSQ4cY8xUY4yHMvPgQk52ptIgnDRgjnU= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f7764ee2-1571-4d73-76ab-08d73b875d63 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:54:47.3805 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g5elzTgLpwiDlc4wVtDvKmn0wGXWe8NpLYr4PzpyTzAxzHugEC/mSOsvTN8wPOmbSxUOUN6Zp/bAVFkqFJv3bT83hNDL+Lmo7ofNmH96rPI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085512_088319_741CBE1A X-CRM114-Status: UNSURE ( 9.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.154.123 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Move all SPI NOR controller driver specific ops in a dedicated structure. 'struct spi_nor' becomes lighter. Use size_t for lengths in 'int (*write_reg)()' and 'int (*read_reg)()'. Rename wite/read_buf to buf, the name of the functions are suggestive enough. Constify buf in int (*write_reg). Comply with these changes in the SPI NOR controller drivers. Suggested-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/aspeed-smc.c | 23 ++++++----- drivers/mtd/spi-nor/cadence-quadspi.c | 39 ++++++++++-------- drivers/mtd/spi-nor/hisi-sfc.c | 22 +++++----- drivers/mtd/spi-nor/intel-spi.c | 24 ++++++----- drivers/mtd/spi-nor/mtk-quadspi.c | 25 +++++++----- drivers/mtd/spi-nor/nxp-spifi.c | 23 +++++++---- drivers/mtd/spi-nor/spi-nor.c | 76 ++++++++++++++++++++--------------- include/linux/mtd/spi-nor.h | 51 +++++++++++++---------- 8 files changed, 166 insertions(+), 117 deletions(-) diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c index 009c1da8574c..2b7cabbb680c 100644 --- a/drivers/mtd/spi-nor/aspeed-smc.c +++ b/drivers/mtd/spi-nor/aspeed-smc.c @@ -320,7 +320,8 @@ static void aspeed_smc_unprep(struct spi_nor *nor, enum spi_nor_ops ops) mutex_unlock(&chip->controller->mutex); } -static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, + size_t len) { struct aspeed_smc_chip *chip = nor->priv; @@ -331,8 +332,8 @@ static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) return 0; } -static int aspeed_smc_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, - int len) +static int aspeed_smc_write_reg(struct spi_nor *nor, u8 opcode, const u8 *buf, + size_t len) { struct aspeed_smc_chip *chip = nor->priv; @@ -746,6 +747,15 @@ static int aspeed_smc_chip_setup_finish(struct aspeed_smc_chip *chip) return 0; } +static const struct spi_nor_controller_ops aspeed_smc_controller_ops = { + .prepare = aspeed_smc_prep, + .unprepare = aspeed_smc_unprep, + .read_reg = aspeed_smc_read_reg, + .write_reg = aspeed_smc_write_reg, + .read = aspeed_smc_read_user, + .write = aspeed_smc_write_user, +}; + static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, struct device_node *np, struct resource *r) { @@ -805,12 +815,7 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, nor->dev = dev; nor->priv = chip; spi_nor_set_flash_node(nor, child); - nor->read = aspeed_smc_read_user; - nor->write = aspeed_smc_write_user; - nor->read_reg = aspeed_smc_read_reg; - nor->write_reg = aspeed_smc_write_reg; - nor->prepare = aspeed_smc_prep; - nor->unprepare = aspeed_smc_unprep; + nor->controller_ops = &aspeed_smc_controller_ops; ret = aspeed_smc_chip_setup_init(chip, r); if (ret) diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c index 7bef63947b29..ebda612641a4 100644 --- a/drivers/mtd/spi-nor/cadence-quadspi.c +++ b/drivers/mtd/spi-nor/cadence-quadspi.c @@ -356,18 +356,19 @@ static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, unsigned int reg) static int cqspi_command_read(struct spi_nor *nor, const u8 *txbuf, const unsigned n_tx, - u8 *rxbuf, const unsigned n_rx) + u8 *rxbuf, size_t n_rx) { struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_st *cqspi = f_pdata->cqspi; void __iomem *reg_base = cqspi->iobase; unsigned int rdreg; unsigned int reg; - unsigned int read_len; + size_t read_len; int status; if (!n_rx || n_rx > CQSPI_STIG_DATA_LEN_MAX || !rxbuf) { - dev_err(nor->dev, "Invalid input argument, len %d rxbuf 0x%p\n", + dev_err(nor->dev, + "Invalid input argument, len %zu rxbuf 0x%p\n", n_rx, rxbuf); return -EINVAL; } @@ -404,19 +405,19 @@ static int cqspi_command_read(struct spi_nor *nor, } static int cqspi_command_write(struct spi_nor *nor, const u8 opcode, - const u8 *txbuf, const unsigned n_tx) + const u8 *txbuf, size_t n_tx) { struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_st *cqspi = f_pdata->cqspi; void __iomem *reg_base = cqspi->iobase; unsigned int reg; unsigned int data; - u32 write_len; + size_t write_len; int ret; if (n_tx > CQSPI_STIG_DATA_LEN_MAX || (n_tx && !txbuf)) { dev_err(nor->dev, - "Invalid input argument, cmdlen %d txbuf 0x%p\n", + "Invalid input argument, cmdlen %zu txbuf 0x%p\n", n_tx, txbuf); return -EINVAL; } @@ -1050,7 +1051,7 @@ static int cqspi_erase(struct spi_nor *nor, loff_t offs) return ret; /* Send write enable, then erase commands. */ - ret = nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0); + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WREN, NULL, 0); if (ret) return ret; @@ -1080,7 +1081,7 @@ static void cqspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops) mutex_unlock(&cqspi->bus_mutex); } -static int cqspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int cqspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len) { int ret; @@ -1091,7 +1092,8 @@ static int cqspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) return ret; } -static int cqspi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int cqspi_write_reg(struct spi_nor *nor, u8 opcode, const u8 *buf, + size_t len) { int ret; @@ -1216,6 +1218,16 @@ static void cqspi_request_mmap_dma(struct cqspi_st *cqspi) init_completion(&cqspi->rx_dma_complete); } +static const struct spi_nor_controller_ops cqspi_controller_ops = { + .prepare = cqspi_prep, + .unprepare = cqspi_unprep, + .read_reg = cqspi_read_reg, + .write_reg = cqspi_write_reg, + .read = cqspi_read, + .write = cqspi_write, + .erase = cqspi_erase, +}; + static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np) { struct platform_device *pdev = cqspi->pdev; @@ -1265,14 +1277,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np) nor->dev = dev; spi_nor_set_flash_node(nor, np); nor->priv = f_pdata; - - nor->read_reg = cqspi_read_reg; - nor->write_reg = cqspi_write_reg; - nor->read = cqspi_read; - nor->write = cqspi_write; - nor->erase = cqspi_erase; - nor->prepare = cqspi_prep; - nor->unprepare = cqspi_unprep; + nor->controller_ops = &cqspi_controller_ops; mtd->name = devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), cs); diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c index c99ed9cdbf9c..a1258216f89d 100644 --- a/drivers/mtd/spi-nor/hisi-sfc.c +++ b/drivers/mtd/spi-nor/hisi-sfc.c @@ -177,7 +177,7 @@ static void hisi_spi_nor_unprep(struct spi_nor *nor, enum spi_nor_ops ops) } static int hisi_spi_nor_op_reg(struct spi_nor *nor, - u8 opcode, int len, u8 optype) + u8 opcode, size_t len, u8 optype) { struct hifmc_priv *priv = nor->priv; struct hifmc_host *host = priv->host; @@ -200,7 +200,7 @@ static int hisi_spi_nor_op_reg(struct spi_nor *nor, } static int hisi_spi_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, - int len) + size_t len) { struct hifmc_priv *priv = nor->priv; struct hifmc_host *host = priv->host; @@ -215,7 +215,7 @@ static int hisi_spi_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, } static int hisi_spi_nor_write_reg(struct spi_nor *nor, u8 opcode, - u8 *buf, int len) + const u8 *buf, size_t len) { struct hifmc_priv *priv = nor->priv; struct hifmc_host *host = priv->host; @@ -311,6 +311,15 @@ static ssize_t hisi_spi_nor_write(struct spi_nor *nor, loff_t to, return len; } +static const struct spi_nor_controller_ops hisi_controller_ops = { + .prepare = hisi_spi_nor_prep, + .unprepare = hisi_spi_nor_unprep, + .read_reg = hisi_spi_nor_read_reg, + .write_reg = hisi_spi_nor_write_reg, + .read = hisi_spi_nor_read, + .write = hisi_spi_nor_write, +}; + /** * Get spi flash device information and register it as a mtd device. */ @@ -357,13 +366,8 @@ static int hisi_spi_nor_register(struct device_node *np, } priv->host = host; nor->priv = priv; + nor->controller_ops = &hisi_controller_ops; - nor->prepare = hisi_spi_nor_prep; - nor->unprepare = hisi_spi_nor_unprep; - nor->read_reg = hisi_spi_nor_read_reg; - nor->write_reg = hisi_spi_nor_write_reg; - nor->read = hisi_spi_nor_read; - nor->write = hisi_spi_nor_write; ret = spi_nor_scan(nor, NULL, &hwcaps); if (ret) return ret; diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c index 43e55a2e9b27..dc38f19ac7ae 100644 --- a/drivers/mtd/spi-nor/intel-spi.c +++ b/drivers/mtd/spi-nor/intel-spi.c @@ -426,7 +426,7 @@ static int intel_spi_opcode_index(struct intel_spi *ispi, u8 opcode, int optype) return 0; } -static int intel_spi_hw_cycle(struct intel_spi *ispi, u8 opcode, int len) +static int intel_spi_hw_cycle(struct intel_spi *ispi, u8 opcode, size_t len) { u32 val, status; int ret; @@ -469,7 +469,7 @@ static int intel_spi_hw_cycle(struct intel_spi *ispi, u8 opcode, int len) return 0; } -static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, int len, +static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, size_t len, int optype) { u32 val = 0, status; @@ -535,7 +535,8 @@ static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, int len, return 0; } -static int intel_spi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int intel_spi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, + size_t len) { struct intel_spi *ispi = nor->priv; int ret; @@ -555,7 +556,8 @@ static int intel_spi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) return intel_spi_read_block(ispi, buf, len); } -static int intel_spi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int intel_spi_write_reg(struct spi_nor *nor, u8 opcode, const u8 *buf, + size_t len) { struct intel_spi *ispi = nor->priv; int ret; @@ -864,6 +866,14 @@ static void intel_spi_fill_partition(struct intel_spi *ispi, } } +static const struct spi_nor_controller_ops intel_spi_controller_ops = { + .read_reg = intel_spi_read_reg, + .write_reg = intel_spi_write_reg, + .read = intel_spi_read, + .write = intel_spi_write, + .erase = intel_spi_erase, +}; + struct intel_spi *intel_spi_probe(struct device *dev, struct resource *mem, const struct intel_spi_boardinfo *info) { @@ -897,11 +907,7 @@ struct intel_spi *intel_spi_probe(struct device *dev, ispi->nor.dev = ispi->dev; ispi->nor.priv = ispi; - ispi->nor.read_reg = intel_spi_read_reg; - ispi->nor.write_reg = intel_spi_write_reg; - ispi->nor.read = intel_spi_read; - ispi->nor.write = intel_spi_write; - ispi->nor.erase = intel_spi_erase; + ispi->nor.controller_ops = &intel_spi_controller_ops; ret = spi_nor_scan(&ispi->nor, NULL, &hwcaps); if (ret) { diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c index 34db01ab6cab..b1691680d174 100644 --- a/drivers/mtd/spi-nor/mtk-quadspi.c +++ b/drivers/mtd/spi-nor/mtk-quadspi.c @@ -151,9 +151,9 @@ static int mtk_nor_execute_cmd(struct mtk_nor *mtk_nor, u8 cmdval) } static int mtk_nor_do_tx_rx(struct mtk_nor *mtk_nor, u8 op, - u8 *tx, int txlen, u8 *rx, int rxlen) + const u8 *tx, size_t txlen, u8 *rx, size_t rxlen) { - int len = 1 + txlen + rxlen; + size_t len = 1 + txlen + rxlen; int i, ret, idx; if (len > MTK_NOR_MAX_SHIFT) @@ -193,7 +193,7 @@ static int mtk_nor_do_tx_rx(struct mtk_nor *mtk_nor, u8 op, } /* Do a WRSR (Write Status Register) command */ -static int mtk_nor_wr_sr(struct mtk_nor *mtk_nor, u8 sr) +static int mtk_nor_wr_sr(struct mtk_nor *mtk_nor, const u8 sr) { writeb(sr, mtk_nor->base + MTK_NOR_PRGDATA5_REG); writeb(8, mtk_nor->base + MTK_NOR_CNT_REG); @@ -354,7 +354,7 @@ static ssize_t mtk_nor_write(struct spi_nor *nor, loff_t to, size_t len, return len; } -static int mtk_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int mtk_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len) { int ret; struct mtk_nor *mtk_nor = nor->priv; @@ -376,8 +376,8 @@ static int mtk_nor_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) return ret; } -static int mtk_nor_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, - int len) +static int mtk_nor_write_reg(struct spi_nor *nor, u8 opcode, const u8 *buf, + size_t len) { int ret; struct mtk_nor *mtk_nor = nor->priv; @@ -419,6 +419,13 @@ static int mtk_nor_enable_clk(struct mtk_nor *mtk_nor) return 0; } +static const struct spi_nor_controller_ops mtk_controller_ops = { + .read_reg = mtk_nor_read_reg, + .write_reg = mtk_nor_write_reg, + .read = mtk_nor_read, + .write = mtk_nor_write, +}; + static int mtk_nor_init(struct mtk_nor *mtk_nor, struct device_node *flash_node) { @@ -438,12 +445,8 @@ static int mtk_nor_init(struct mtk_nor *mtk_nor, nor->dev = mtk_nor->dev; nor->priv = mtk_nor; spi_nor_set_flash_node(nor, flash_node); + nor->controller_ops = &mtk_controller_ops; - /* fill the hooks to spi nor */ - nor->read = mtk_nor_read; - nor->read_reg = mtk_nor_read_reg; - nor->write = mtk_nor_write; - nor->write_reg = mtk_nor_write_reg; nor->mtd.name = "mtk_nor"; /* initialized with NULL */ ret = spi_nor_scan(nor, NULL, &hwcaps); diff --git a/drivers/mtd/spi-nor/nxp-spifi.c b/drivers/mtd/spi-nor/nxp-spifi.c index 4a871587392b..9a5b1a7c636a 100644 --- a/drivers/mtd/spi-nor/nxp-spifi.c +++ b/drivers/mtd/spi-nor/nxp-spifi.c @@ -123,7 +123,8 @@ static int nxp_spifi_set_memory_mode_on(struct nxp_spifi *spifi) return ret; } -static int nxp_spifi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int nxp_spifi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, + size_t len) { struct nxp_spifi *spifi = nor->priv; u32 cmd; @@ -145,7 +146,8 @@ static int nxp_spifi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) return nxp_spifi_wait_for_cmd(spifi); } -static int nxp_spifi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) +static int nxp_spifi_write_reg(struct spi_nor *nor, u8 opcode, const u8 *buf, + size_t len) { struct nxp_spifi *spifi = nor->priv; u32 cmd; @@ -263,9 +265,18 @@ static int nxp_spifi_setup_memory_cmd(struct nxp_spifi *spifi) static void nxp_spifi_dummy_id_read(struct spi_nor *nor) { u8 id[SPI_NOR_MAX_ID_LEN]; - nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN); + nor->controller_ops->read_reg(nor, SPINOR_OP_RDID, id, + SPI_NOR_MAX_ID_LEN); } +static const struct spi_nor_controller_ops nxp_spifi_controller_ops = { + .read_reg = nxp_spifi_read_reg, + .write_reg = nxp_spifi_write_reg, + .read = nxp_spifi_read, + .write = nxp_spifi_write, + .erase = nxp_spifi_erase, +}; + static int nxp_spifi_setup_flash(struct nxp_spifi *spifi, struct device_node *np) { @@ -332,11 +343,7 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi, spifi->nor.dev = spifi->dev; spi_nor_set_flash_node(&spifi->nor, np); spifi->nor.priv = spifi; - spifi->nor.read = nxp_spifi_read; - spifi->nor.write = nxp_spifi_write; - spifi->nor.erase = nxp_spifi_erase; - spifi->nor.read_reg = nxp_spifi_read_reg; - spifi->nor.write_reg = nxp_spifi_write_reg; + spifi->nor.controller_ops = &nxp_spifi_controller_ops; /* * The first read on a hard reset isn't reliable so do a diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 1d8621d43160..b8c7ded0f145 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -338,7 +338,7 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, if (nor->spimem) return spi_nor_spimem_read_data(nor, from, len, buf); - return nor->read(nor, from, len, buf); + return nor->controller_ops->read(nor, from, len, buf); } /** @@ -385,7 +385,7 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, if (nor->spimem) return spi_nor_spimem_write_data(nor, to, len, buf); - return nor->write(nor, to, len, buf); + return nor->controller_ops->write(nor, to, len, buf); } /* @@ -406,7 +406,8 @@ static int read_sr(struct spi_nor *nor) ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->read_reg(nor, SPINOR_OP_RDSR, nor->bouncebuf, 1); + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, + nor->bouncebuf, 1); } if (ret < 0) { @@ -435,7 +436,8 @@ static int read_fsr(struct spi_nor *nor) ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->read_reg(nor, SPINOR_OP_RDFSR, nor->bouncebuf, 1); + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDFSR, + nor->bouncebuf, 1); } if (ret < 0) { @@ -464,7 +466,8 @@ static int read_cr(struct spi_nor *nor) ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->read_reg(nor, SPINOR_OP_RDCR, nor->bouncebuf, 1); + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDCR, + nor->bouncebuf, 1); } if (ret < 0) { @@ -492,7 +495,8 @@ static int write_sr(struct spi_nor *nor, u8 val) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_WRSR, nor->bouncebuf, 1); + return nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR, + nor->bouncebuf, 1); } /* @@ -511,7 +515,7 @@ static int write_enable(struct spi_nor *nor) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0); + return nor->controller_ops->write_reg(nor, SPINOR_OP_WREN, NULL, 0); } /* @@ -529,7 +533,7 @@ static int write_disable(struct spi_nor *nor) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_WRDI, NULL, 0); + return nor->controller_ops->write_reg(nor, SPINOR_OP_WRDI, NULL, 0); } static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) @@ -631,8 +635,9 @@ static int macronix_set_4byte(struct spi_nor *nor, bool enable) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, enable ? SPINOR_OP_EN4B : SPINOR_OP_EX4B, - NULL, 0); + return nor->controller_ops->write_reg(nor, enable ? SPINOR_OP_EN4B : + SPINOR_OP_EX4B, + NULL, 0); } static int st_micron_set_4byte(struct spi_nor *nor, bool enable) @@ -660,7 +665,8 @@ static int spansion_set_4byte(struct spi_nor *nor, bool enable) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_BRWR, nor->bouncebuf, 1); + return nor->controller_ops->write_reg(nor, SPINOR_OP_BRWR, + nor->bouncebuf, 1); } static int spi_nor_write_ear(struct spi_nor *nor, u8 ear) @@ -677,7 +683,8 @@ static int spi_nor_write_ear(struct spi_nor *nor, u8 ear) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_WREAR, nor->bouncebuf, 1); + return nor->controller_ops->write_reg(nor, SPINOR_OP_WREAR, + nor->bouncebuf, 1); } static int winbond_set_4byte(struct spi_nor *nor, bool enable) @@ -712,7 +719,7 @@ static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) return spi_mem_exec_op(nor->spimem, &op); } - return nor->read_reg(nor, SPINOR_OP_XRDSR, sr, 1); + return nor->controller_ops->read_reg(nor, SPINOR_OP_XRDSR, sr, 1); } static int s3an_sr_ready(struct spi_nor *nor) @@ -740,7 +747,7 @@ static int spi_nor_clear_sr(struct spi_nor *nor) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_CLSR, NULL, 0); + return nor->controller_ops->write_reg(nor, SPINOR_OP_CLSR, NULL, 0); } static int spi_nor_sr_ready(struct spi_nor *nor) @@ -774,7 +781,7 @@ static int spi_nor_clear_fsr(struct spi_nor *nor) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0); + return nor->controller_ops->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0); } static int spi_nor_fsr_ready(struct spi_nor *nor) @@ -871,7 +878,8 @@ static int erase_chip(struct spi_nor *nor) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0); + return nor->controller_ops->write_reg(nor, SPINOR_OP_CHIP_ERASE, + NULL, 0); } static int spi_nor_lock_and_prep(struct spi_nor *nor, enum spi_nor_ops ops) @@ -880,10 +888,9 @@ static int spi_nor_lock_and_prep(struct spi_nor *nor, enum spi_nor_ops ops) mutex_lock(&nor->lock); - if (nor->prepare) { - ret = nor->prepare(nor, ops); + if (nor->controller_ops && nor->controller_ops->prepare) { + ret = nor->controller_ops->prepare(nor, ops); if (ret) { - dev_err(nor->dev, "failed in the preparation.\n"); mutex_unlock(&nor->lock); return ret; } @@ -893,8 +900,8 @@ static int spi_nor_lock_and_prep(struct spi_nor *nor, enum spi_nor_ops ops) static void spi_nor_unlock_and_unprep(struct spi_nor *nor, enum spi_nor_ops ops) { - if (nor->unprepare) - nor->unprepare(nor, ops); + if (nor->controller_ops && nor->controller_ops->unprepare) + nor->controller_ops->unprepare(nor, ops); mutex_unlock(&nor->lock); } @@ -935,8 +942,8 @@ static int spi_nor_erase_sector(struct spi_nor *nor, u32 addr) addr = spi_nor_convert_addr(nor, addr); - if (nor->erase) - return nor->erase(nor, addr); + if (nor->controller_ops && nor->controller_ops->erase) + return nor->controller_ops->erase(nor, addr); if (nor->spimem) { struct spi_mem_op op = @@ -957,8 +964,8 @@ static int spi_nor_erase_sector(struct spi_nor *nor, u32 addr) addr >>= 8; } - return nor->write_reg(nor, nor->erase_opcode, nor->bouncebuf, - nor->addr_width); + return nor->controller_ops->write_reg(nor, nor->erase_opcode, + nor->bouncebuf, nor->addr_width); } /** @@ -1678,7 +1685,8 @@ static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->write_reg(nor, SPINOR_OP_WRSR, sr_cr, 2); + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR, + sr_cr, 2); } if (ret < 0) { @@ -1873,7 +1881,7 @@ static int spi_nor_write_sr2(struct spi_nor *nor, u8 *sr2) return spi_mem_exec_op(nor->spimem, &op); } - return nor->write_reg(nor, SPINOR_OP_WRSR2, sr2, 1); + return nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR2, sr2, 1); } static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) @@ -1888,7 +1896,7 @@ static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) return spi_mem_exec_op(nor->spimem, &op); } - return nor->read_reg(nor, SPINOR_OP_RDSR2, sr2, 1); + return nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR2, sr2, 1); } /** @@ -2520,8 +2528,8 @@ static const struct flash_info *spi_nor_read_id(struct spi_nor *nor) tmp = spi_mem_exec_op(nor->spimem, &op); } else { - tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, - SPI_NOR_MAX_ID_LEN); + tmp = nor->controller_ops->read_reg(nor, SPINOR_OP_RDID, id, + SPI_NOR_MAX_ID_LEN); } if (tmp < 0) { dev_err(nor->dev, "error %d reading JEDEC ID\n", tmp); @@ -2722,9 +2730,11 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, static int spi_nor_check(struct spi_nor *nor) { if (!nor->dev || - (!nor->spimem && - (!nor->read || !nor->write || !nor->read_reg || - !nor->write_reg))) { + (!nor->spimem && nor->controller_ops && + (!nor->controller_ops->read || + !nor->controller_ops->write || + !nor->controller_ops->read_reg || + !nor->controller_ops->write_reg))) { pr_err("spi-nor: please fill all the necessary fields!\n"); return -EINVAL; } diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index fc0b4b19c900..d1d736d3c8ab 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -466,6 +466,34 @@ enum spi_nor_pp_command_index { struct spi_nor; /** + * struct spi_nor_controller_ops - SPI NOR controller driver specific + * operations. + * @prepare: [OPTIONAL] do some preparations for the + * read/write/erase/lock/unlock operations. + * @unprepare: [OPTIONAL] do some post work after the + * read/write/erase/lock/unlock operations. + * @read_reg: read out the register. + * @write_reg: write data to the register. + * @read: read data from the SPI NOR. + * @write: write data to the SPI NOR. + * @erase: erase a sector of the SPI NOR at the offset @offs; if + * not provided by the driver, spi-nor will send the erase + * opcode via write_reg(). + */ +struct spi_nor_controller_ops { + int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops); + void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops); + int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len); + int (*write_reg)(struct spi_nor *nor, u8 opcode, const u8 *buf, + size_t len); + + ssize_t (*read)(struct spi_nor *nor, loff_t from, size_t len, u8 *buf); + ssize_t (*write)(struct spi_nor *nor, loff_t to, size_t len, + const u8 *buf); + int (*erase)(struct spi_nor *nor, loff_t offs); +}; + +/** * struct spi_nor_locking_ops - SPI NOR locking methods * @lock: lock a region of the SPI NOR. * @unlock: unlock a region of the SPI NOR. @@ -549,17 +577,7 @@ struct flash_info; * @read_proto: the SPI protocol for read operations * @write_proto: the SPI protocol for write operations * @reg_proto the SPI protocol for read_reg/write_reg/erase operations - * @prepare: [OPTIONAL] do some preparations for the - * read/write/erase/lock/unlock operations - * @unprepare: [OPTIONAL] do some post work after the - * read/write/erase/lock/unlock operations - * @read_reg: [DRIVER-SPECIFIC] read out the register - * @write_reg: [DRIVER-SPECIFIC] write data to the register - * @read: [DRIVER-SPECIFIC] read data from the SPI NOR - * @write: [DRIVER-SPECIFIC] write data to the SPI NOR - * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR - * at the offset @offs; if not provided by the driver, - * spi-nor will send the erase opcode via write_reg() + * @controller_ops: SPI NOR controller driver specific operations. * @clear_sr_bp: [FLASH-SPECIFIC] clears the Block Protection Bits from * the SPI NOR Status Register. * @params: [FLASH-SPECIFIC] SPI-NOR flash parameters and settings. @@ -588,16 +606,7 @@ struct spi_nor { bool sst_write_second; u32 flags; - int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops); - void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops); - int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len); - int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len); - - ssize_t (*read)(struct spi_nor *nor, loff_t from, - size_t len, u_char *read_buf); - ssize_t (*write)(struct spi_nor *nor, loff_t to, - size_t len, const u_char *write_buf); - int (*erase)(struct spi_nor *nor, loff_t offs); + const struct spi_nor_controller_ops *controller_ops; int (*clear_sr_bp)(struct spi_nor *nor); struct spi_nor_flash_parameter params; From patchwork Tue Sep 17 15:54:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 005D116B1 for ; Tue, 17 Sep 2019 15:57:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDAED2171F for ; Tue, 17 Sep 2019 15:57:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HNLT4Xn1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="AENjBH9C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDAED2171F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=K+zYMVjP0xK1egoZkZgEqGNkS6YKOF25T9ntWcbg7ts=; b=HNLT4Xn1EIGOcN O7WsilY+Qw3Y4YBcPCdqu4let737QtdWgFFQnIozFZ4cuyGcCqehJkdkxoZL2d1Mwwltep/8SBVbj FbASMYQzcVwd93zL1nPo0iHwsgWVYDlSiCzKwK8cmf9FJP/feo9XDZ1oVShGCYTAXp4YTWlD7Q4uI PR/AL0ukKaAR4LtMgr3AGjPkDMX5fCfgyxZLqzKmX9G5hJJY7deoDAHHLkv1T3pppIhRiaP57dacJ KnzhzYAxfEaH9w+0RfoDpoDiYBEp+lXbnB8ulotfiKoGB77kkF3abq3zYr+fGF3YvihXjV3HV3vxs llgPe9Zpkm2yq/Iq/eKw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFrY-0000wU-Ku; Tue, 17 Sep 2019 15:57:56 +0000 Received: from esa3.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFoi-0006Qg-TD; Tue, 17 Sep 2019 15:55:02 +0000 Received-SPF: Pass (esa3.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa3.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa3.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: /RvD3GpP3Xfx8cxKqn8deYK4TLH4ffwB8dlD8pMSyPEQx4pyaKUJZGiBAPkOUhlEl5Etu32VQ9 ESyOiuVeUBfaxRlPCYyDwhPsfnnRZVExyD/RWvXjUEX3XVoR8wGFUVTy9keYDGkfbiKWWPtoeu 6AUxJMdUdwq5tNLBwUYnhI05BY6Dip7QOm4Tz4UkxJnPMq5Cf7dYiANG2qEjFg22Y4U20aDGnj ZEvuzXvN/6efluOMEAF180zrhvP6ysi4AeW0P+PSssMPRm1yGzuQ1TfCIdYtELOsg/Mz/X6dkf 6GU= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="49417066" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:54:59 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:54:51 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:54:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XT0+uGKxogCeHdu9D3YFKZ+qMMGvv9qW1LUCYWf1Hyx8fD7TuwV26bkqFHQVm4AMBcMsCFoGAUycAPCkjudC5J6EyBLcjJAN/qOhZPZQlHgJLDE1zfDDV4PtHl+jOq+2w50lGx1xolcTdGFJ0slp8Im+ZOyXh+tNHNJRgcaswCE5xt01mtzwOcrhqQAaILLj/eD1eiNcje2KuXahI1rp9ZMVVwCYUFScjN69bLxcR67jz9SVBT2SuOB3WEQF+cOP66x0E9L9REyBZjJALAXwbTw9Ko/5xNerOrpCAwcaHrHoGw3jT0UIOgSOxZ7/g2HbD772PXOmjOjtO7W03rszGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fUnI9G+jAP6wYWzRUmHCiHV/8SdWFcWs90zq4tIEEaQ=; b=RSi7X3kPypu6EEZK/InN/ieFD8Y+Pte7/7VwIbQSOcStjkO92kylUXZGREr15EWs1y9rFtockajSZLDSvThC6S4dd8p+MEqW2p3jqcvfjzh+1iy6f3emCAISX6Ms+IdOw8oxAVYZ+YM+3bPDGMs1pUuYv9l4/aSS8x9bJFuJhNbyJ0l6uSfX/BbIOKmmmT5vYA9OCmAps4LX6hB2J54tEIkT/TnM6AGgFbX7AcbiyMrkhPMxbf7skUgLZd/MAro/CTfnPvg+AUoBCoDZETleEMoq4UQ+sDmdyg7bEh8zqBYTp45Unc85TLu5wZ6fdrA+Y5dQWIQ2mXJSiv56NRU6uw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fUnI9G+jAP6wYWzRUmHCiHV/8SdWFcWs90zq4tIEEaQ=; b=AENjBH9CLwdIw0XZBFpGWL69nL3Ju/JZG1KphDk9IaJyv9+PKDBi4Cf9Ha1PIscLBbyI9Zn6Mw0ooBeduy00A+xah4L4Yvu9TU8YcpM3tgoJs9W2SnwYQag5S+AJjxbTCZ8lKwjIFybQwOFySCCNwIFROlIKZfdcLBv6/8TYYWc= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:54:50 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:54:50 +0000 From: To: , , , , , Subject: [PATCH 03/23] mtd: spi-nor: cadence-quadspi: Fix cqspi_command_read() definition Thread-Topic: [PATCH 03/23] mtd: spi-nor: cadence-quadspi: Fix cqspi_command_read() definition Thread-Index: AQHVbXA9hfYbZR5ivU2ka2qtYlUz9g== Date: Tue, 17 Sep 2019 15:54:50 +0000 Message-ID: <20190917155426.7432-4-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5479ccf3-56e8-41f2-fb60-08d73b875f55 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 6d2lI961zrbF0OLuLwMsayae6gaa7lcFz9ldKGl8WWvvgvLANfZdj4BmQhS8t9AJvzgmVx2a3UlOaetl940pmnTrbU7mdfi/lkh3ESWw1b2pOfXgUHdgWAUXu0GvvEz+Jsz98R7TndAF5xYR02kIQF3giLItceHEz9u14pC5SW8QQDjbIEDFpqIjNx6BpGlTNOiMppa5Ta5SMwW+buYDMi2NvhgCYy2PkqRiZozOiMWm9eSLSUedY+pdUpv3VO2oTxlhCTe5gbVFAMBsz+R6m6cT4DmyXu+jObfOO0u1CodQq16P0/R1dY7bXjcSdsFA6Aw+eviJjnywBCq1Vxi2gCJdOpJJXN6vUZrFrwYlJy/SSBje27huwUnQq7UPP9MM1XTbR8e/HzcR60bAHtiZd4bwLhghId+ewJk60HBTjK4= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 5479ccf3-56e8-41f2-fb60-08d73b875f55 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:54:50.5486 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3OMKr2Y7P/ak7kRUAmS12CA8gaARH1Q4/YqdrSLLklgH+IMSOb5rA8Plc1QufzwQYIK/t/ADR3SCDA2Jq03zeYytvskszmyab0GiOtSSGuQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085501_260276_FE510E94 X-CRM114-Status: UNSURE ( 8.91 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.153.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus n_tx was never used, drop it. Replace 'const u8 *txbuf' with 'u8 opcode', to comply with the SPI NOR int (*read_reg)() method. The 'const' qualifier has no meaning for parameters passed by value, drop it. Going furher, the opcode was passed to cqspi_calc_rdreg() and never used, drop it. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/cadence-quadspi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c index ebda612641a4..22008fecd326 100644 --- a/drivers/mtd/spi-nor/cadence-quadspi.c +++ b/drivers/mtd/spi-nor/cadence-quadspi.c @@ -285,7 +285,7 @@ static irqreturn_t cqspi_irq_handler(int this_irq, void *dev) return IRQ_HANDLED; } -static unsigned int cqspi_calc_rdreg(struct spi_nor *nor, const u8 opcode) +static unsigned int cqspi_calc_rdreg(struct spi_nor *nor) { struct cqspi_flash_pdata *f_pdata = nor->priv; u32 rdreg = 0; @@ -354,8 +354,7 @@ static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, unsigned int reg) return cqspi_wait_idle(cqspi); } -static int cqspi_command_read(struct spi_nor *nor, - const u8 *txbuf, const unsigned n_tx, +static int cqspi_command_read(struct spi_nor *nor, u8 opcode, u8 *rxbuf, size_t n_rx) { struct cqspi_flash_pdata *f_pdata = nor->priv; @@ -373,9 +372,9 @@ static int cqspi_command_read(struct spi_nor *nor, return -EINVAL; } - reg = txbuf[0] << CQSPI_REG_CMDCTRL_OPCODE_LSB; + reg = opcode << CQSPI_REG_CMDCTRL_OPCODE_LSB; - rdreg = cqspi_calc_rdreg(nor, txbuf[0]); + rdreg = cqspi_calc_rdreg(nor); writel(rdreg, reg_base + CQSPI_REG_RD_INSTR); reg |= (0x1 << CQSPI_REG_CMDCTRL_RD_EN_LSB); @@ -471,7 +470,7 @@ static int cqspi_read_setup(struct spi_nor *nor) unsigned int reg; reg = nor->read_opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB; - reg |= cqspi_calc_rdreg(nor, nor->read_opcode); + reg |= cqspi_calc_rdreg(nor); /* Setup dummy clock cycles */ dummy_clk = nor->read_dummy; @@ -604,7 +603,7 @@ static int cqspi_write_setup(struct spi_nor *nor) /* Set opcode. */ reg = nor->program_opcode << CQSPI_REG_WR_INSTR_OPCODE_LSB; writel(reg, reg_base + CQSPI_REG_WR_INSTR); - reg = cqspi_calc_rdreg(nor, nor->program_opcode); + reg = cqspi_calc_rdreg(nor); writel(reg, reg_base + CQSPI_REG_RD_INSTR); reg = readl(reg_base + CQSPI_REG_SIZE); @@ -1087,7 +1086,7 @@ static int cqspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len) ret = cqspi_set_protocol(nor, 0); if (!ret) - ret = cqspi_command_read(nor, &opcode, 1, buf, len); + ret = cqspi_command_read(nor, opcode, buf, len); return ret; } From patchwork Tue Sep 17 15:54:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 452FD112B for ; Tue, 17 Sep 2019 15:58:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1AA91214AF for ; Tue, 17 Sep 2019 15:58:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mSYvG9vT"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="jwkfi7qc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AA91214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=4j69F3lrTnVFkD2oyXlATuobTu08kQ1PufufXXb93iI=; b=mSYvG9vTO9hZvW JO0uXrXqk3fmD82SFJGDhjj48YohUx3j9g22gRF1bzl6qN+5zq5o+a/BgH0FPTMyI3DvQeTwKHC3A R8yEwNKgtkIBR+CkZSCh5jrEfKnr2v9fFQmLXij/6ioajC4OpBAS9f7GopMQjIeaaXSNXvRBQF2D9 OahLonitYhmZwcJtdubsKtiyjmjoZ6sUGGBIyGkgNHJnkwoaQHOvgZsBCEw1WeZO5VaEi4DLycXGi vtLdOE9GTAkyKn8sFHwji1/x92Q0P5VGCky3K5LUO6h76ixJrXQjiLwKaLFYFx3VD6U+xJiiUMswS Mb36ITZTJIgPfMDU3PeQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFs5-0001Sk-JX; Tue, 17 Sep 2019 15:58:29 +0000 Received: from esa3.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFol-0006Qg-4C; Tue, 17 Sep 2019 15:55:06 +0000 Received-SPF: Pass (esa3.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa3.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa3.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: i1YCUCkhw1rIM289kSMcrL2bJZz/ALvyYE6hjs7FW0KAG3+87yU2ppuWoRYLfjQ/m2zgwEndvh Do8ZM73kSs6M6iYjdVW63BHqzhGfyNcWFRrUgRjYNra62ymoNZHxLeWinyHxbr2DS43cqPaQj1 wVygKAZsfHIvH8JqPM/7PhM5WrwbF7aUR2tSlu4/H/dFtqC4nEQ1LLVXZlczej4+qcCO4TRtSv 0QfitUNhMr26/LR+qwV4eqwDPBMOOBCm4PuzG9MSmnySQcKM/1M6bVMARfcKS1vUUBMzSi9EnT L94= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="49417074" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:01 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:54:55 -0700 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:54:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=alH5QBInK+u2IksR1tfydGQs7+AYHrZgQ5ttUOUJsE7Xt9igNRUqH271Ncf/7N7MmKCDSwsa6G+iL7rxvGNOp45hPpTAgAceeEC0VlWjcG/ILqwCorMEXrppxAK67VcaPVXuc+TG8ypRa3pP1SSGO/3kzd5H3z+gd0Ja8YzKMYha+/4FmcaLGLRQHO73fy/G0J27JURzuMO3LUPLvLxJ/QLef39t60zGxOpdo6pZFtkcZoPG8BOUXgdvHNnkEU9aNJadQVIKp2rOPezYXyF62ym9rbCC+ckjg6EruRCEBGkYCsgCrhFqiyjOWv6rfzl1C9vW4Wtn0pU3yDReOvTBqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UdQW3ZK2q3HvpbebtekZEnLNBc52w5XBKk3JADV4DdM=; b=fonDr8dqDErl9MKCNC4A7+wQz6NftYDR8dJejYvjYPLsPQRc/KLyUHaeGIDVUrcRXHTESwpqDYle9WFYpFoSwW5SvC6a/jO+WFdJBqQD4E2b3xdgLOAuUqQ++5e5xPP1z20oUtqaN21prfTWgWAGbaRZ0n/6FFhlqp8FcIWk4kOOuqNY0XOGSSYNEmRYJyfPusjPXbMGKbplx+IycL3OmaJew2lyUuCLUe99Rw2RTaeUw5B9onP+HWvmDBOLLW5xlTbVkFz5spaQtrr3cJYCw+KGVLROuKdoPxYLl5e7vPa989l5GnX4QAmV4aVuOi8oSZRSrb4B2x/2pGTJgoHhIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UdQW3ZK2q3HvpbebtekZEnLNBc52w5XBKk3JADV4DdM=; b=jwkfi7qcQcGglj/udr0aBFeA/HpVdUrXqKrnyM/ARi8vuAsky3jOZtSAXzMGIF+n7l709te4x9m25qEckCIz9lc6GmF1/BktMOERllA4aus1EHsaQA/qRmRuFR+s32a0njeob3t+NmD34XK/F+aJ2OaPyPUH5jdXdPuclDgvLaQ= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3565.namprd11.prod.outlook.com (20.178.250.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.13; Tue, 17 Sep 2019 15:54:54 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:54:54 +0000 From: To: , , , , , Subject: [PATCH 04/23] mtd: spi-nor: Rename nor->params to nor->flash Thread-Topic: [PATCH 04/23] mtd: spi-nor: Rename nor->params to nor->flash Thread-Index: AQHVbXA/vVteBhlODESmRvp5yShsdg== Date: Tue, 17 Sep 2019 15:54:53 +0000 Message-ID: <20190917155426.7432-5-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3a86b23c-66fd-43ac-072d-08d73b876141 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3565; x-ms-traffictypediagnostic: MN2PR11MB3565: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(346002)(366004)(39860400002)(396003)(199004)(189003)(52314003)(6436002)(11346002)(2201001)(64756008)(486006)(2501003)(50226002)(186003)(107886003)(66476007)(66556008)(8676002)(71200400001)(26005)(66446008)(478600001)(66946007)(81156014)(446003)(25786009)(4326008)(476003)(2616005)(8936002)(71190400001)(6512007)(6506007)(386003)(52116002)(36756003)(14444005)(86362001)(81166006)(76176011)(6116002)(66066001)(102836004)(54906003)(305945005)(7416002)(3846002)(316002)(256004)(110136005)(1076003)(5660300002)(30864003)(7736002)(2906002)(6486002)(14454004)(99286004)(559001)(579004)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3565; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Qe537QW2SVRVKCrCWuTrzjN1R+sZZttVl+lwjtI5mej1BmhAhaywKetMJJAr2jWQrePsH9yCD9ChKrjFurHhThCJ6xDOhLfne8Ava5aKXPTUsKf5Y+XP57O2uqsHmm5eWUdLlQKkKFfWz9x8rePOfSzntob9Tv25bD0nn0K6xrx82cMofVPsL+bIJ4mAgWZYL6rA+s+lc0NNQPRDFvbJsBxW1y6w0VPunWBp6ZspY3pbHNIXrGuFm8GHzmJJHlYRh9qbI1iDs7DoYEN5oWTGOi/6DFDc81OP/LUirmV5RZ7M61g8u6hPmjQM3y1ct6zFP8m7c2QPWFKRZVxCv+Luu6j8pwjq3ZTmwG6lu9hmAQGP2LazcKk1qyA5HGDmQ+NTsP0+8zEjjKTbchpeCUORvcIyvpN/rbKO5+wiFv13qJA= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 3a86b23c-66fd-43ac-072d-08d73b876141 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:54:53.8687 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dFj8kVDUlM+CdiFVYXH321a4tisvOhmMNSwbOL9hRz05aRIzPLTxaaeOeh8YLWWnvTM1X3h1jkQxqoGdnnasumOBbrWesJgzjh8Rl3FPrXg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3565 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085503_477029_2E18D652 X-CRM114-Status: GOOD ( 13.64 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.153.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Rename nor->params to nor->flash for a clearer separation between the controller and flash operations. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 286 +++++++++++++++++++++--------------------- include/linux/mtd/spi-nor.h | 12 +- 2 files changed, 149 insertions(+), 149 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b8c7ded0f145..7d0c1b598250 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -172,7 +172,7 @@ struct spi_nor_fixups { int (*post_bfpt)(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt, - struct spi_nor_flash_parameter *params); + struct spi_nor_flash_parameter *flash); void (*post_sfdp)(struct spi_nor *nor); }; @@ -608,7 +608,7 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor) nor->erase_opcode = spi_nor_convert_3to4_erase(nor->erase_opcode); if (!spi_nor_has_uniform_erase(nor)) { - struct spi_nor_erase_map *map = &nor->params.erase_map; + struct spi_nor_erase_map *map = &nor->flash.erase_map; struct spi_nor_erase_type *erase; int i; @@ -927,10 +927,10 @@ static u32 s3an_convert_addr(struct spi_nor *nor, u32 addr) static u32 spi_nor_convert_addr(struct spi_nor *nor, loff_t addr) { - if (!nor->params.convert_addr) + if (!nor->flash.convert_addr) return addr; - return nor->params.convert_addr(nor, addr); + return nor->flash.convert_addr(nor, addr); } /* @@ -1140,7 +1140,7 @@ static int spi_nor_init_erase_cmd_list(struct spi_nor *nor, struct list_head *erase_list, u64 addr, u32 len) { - const struct spi_nor_erase_map *map = &nor->params.erase_map; + const struct spi_nor_erase_map *map = &nor->flash.erase_map; const struct spi_nor_erase_type *erase, *prev_erase = NULL; struct spi_nor_erase_region *region; struct spi_nor_erase_command *cmd = NULL; @@ -1628,7 +1628,7 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) if (ret) return ret; - ret = nor->params.locking_ops->lock(nor, ofs, len); + ret = nor->flash.locking_ops->lock(nor, ofs, len); spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_UNLOCK); return ret; @@ -1643,7 +1643,7 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) if (ret) return ret; - ret = nor->params.locking_ops->unlock(nor, ofs, len); + ret = nor->flash.locking_ops->unlock(nor, ofs, len); spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK); return ret; @@ -1658,7 +1658,7 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) if (ret) return ret; - ret = nor->params.locking_ops->is_locked(nor, ofs, len); + ret = nor->flash.locking_ops->is_locked(nor, ofs, len); spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK); return ret; @@ -2093,7 +2093,7 @@ static int is25lp256_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { /* * IS25LP256 supports 4B opcodes, but the BFPT advertises a @@ -2115,7 +2115,7 @@ static int mx25l25635_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { /* * MX25L25635F supports 4B opcodes but MX25L25635E does not. @@ -2144,7 +2144,7 @@ static void gd25q256_default_init(struct spi_nor *nor) * indicate the quad_enable method for this case, we need * to set it in the default_init fixup hook. */ - nor->params.quad_enable = macronix_quad_enable; + nor->flash.quad_enable = macronix_quad_enable; } static struct spi_nor_fixups gd25q256_fixups = { @@ -2777,7 +2777,7 @@ static int s3an_nor_setup(struct spi_nor *nor, nor->mtd.erasesize = 8 * nor->page_size; } else { /* Flash in Default addressing mode */ - nor->params.convert_addr = s3an_convert_addr; + nor->flash.convert_addr = s3an_convert_addr; nor->mtd.erasesize = nor->info->sector_size; } @@ -3017,7 +3017,7 @@ static int spi_nor_spimem_check_pp(struct spi_nor *nor, static void spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, u32 *hwcaps) { - struct spi_nor_flash_parameter *params = &nor->params; + struct spi_nor_flash_parameter *flash = &nor->flash; unsigned int cap; /* DTR modes are not supported yet, mask them all. */ @@ -3034,7 +3034,7 @@ spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, u32 *hwcaps) rdidx = spi_nor_hwcaps_read2cmd(BIT(cap)); if (rdidx >= 0 && - spi_nor_spimem_check_readop(nor, ¶ms->reads[rdidx])) + spi_nor_spimem_check_readop(nor, &flash->reads[rdidx])) *hwcaps &= ~BIT(cap); ppidx = spi_nor_hwcaps_pp2cmd(BIT(cap)); @@ -3042,7 +3042,7 @@ spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, u32 *hwcaps) continue; if (spi_nor_spimem_check_pp(nor, - ¶ms->page_programs[ppidx])) + &flash->page_programs[ppidx])) *hwcaps &= ~BIT(cap); } } @@ -3091,7 +3091,7 @@ spi_nor_set_read_settings_from_bfpt(struct spi_nor_read_command *read, } struct sfdp_bfpt_read { - /* The Fast Read x-y-z hardware capability in params->hwcaps.mask. */ + /* The Fast Read x-y-z hardware capability in flash->hwcaps.mask. */ u32 hwcaps; /* @@ -3322,11 +3322,11 @@ static int spi_nor_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { if (nor->info->fixups && nor->info->fixups->post_bfpt) return nor->info->fixups->post_bfpt(nor, bfpt_header, bfpt, - params); + flash); return 0; } @@ -3336,7 +3336,7 @@ spi_nor_post_bfpt_fixups(struct spi_nor *nor, * @nor: pointer to a 'struct spi_nor' * @bfpt_header: pointer to the 'struct sfdp_parameter_header' describing * the Basic Flash Parameter Table length and version - * @params: pointer to the 'struct spi_nor_flash_parameter' to be + * @flash: pointer to the 'struct spi_nor_flash_parameter' to be * filled * * The Basic Flash Parameter Table is the main and only mandatory table as @@ -3363,9 +3363,9 @@ spi_nor_post_bfpt_fixups(struct spi_nor *nor, */ static int spi_nor_parse_bfpt(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { - struct spi_nor_erase_map *map = ¶ms->erase_map; + struct spi_nor_erase_map *map = &flash->erase_map; struct spi_nor_erase_type *erase_type = map->erase_type; struct sfdp_bfpt bfpt; size_t len; @@ -3406,23 +3406,23 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, } /* Flash Memory Density (in bits). */ - params->size = bfpt.dwords[BFPT_DWORD(2)]; - if (params->size & BIT(31)) { - params->size &= ~BIT(31); + flash->size = bfpt.dwords[BFPT_DWORD(2)]; + if (flash->size & BIT(31)) { + flash->size &= ~BIT(31); /* - * Prevent overflows on params->size. Anyway, a NOR of 2^64 + * Prevent overflows on flash->size. Anyway, a NOR of 2^64 * bits is unlikely to exist so this error probably means * the BFPT we are reading is corrupted/wrong. */ - if (params->size > 63) + if (flash->size > 63) return -EINVAL; - params->size = 1ULL << params->size; + flash->size = 1ULL << flash->size; } else { - params->size++; + flash->size++; } - params->size >>= 3; /* Convert to bytes. */ + flash->size >>= 3; /* Convert to bytes. */ /* Fast Read settings. */ for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_reads); i++) { @@ -3430,13 +3430,13 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, struct spi_nor_read_command *read; if (!(bfpt.dwords[rd->supported_dword] & rd->supported_bit)) { - params->hwcaps.mask &= ~rd->hwcaps; + flash->hwcaps.mask &= ~rd->hwcaps; continue; } - params->hwcaps.mask |= rd->hwcaps; + flash->hwcaps.mask |= rd->hwcaps; cmd = spi_nor_hwcaps_read2cmd(rd->hwcaps); - read = ¶ms->reads[cmd]; + read = &flash->reads[cmd]; half = bfpt.dwords[rd->settings_dword] >> rd->settings_shift; spi_nor_set_read_settings_from_bfpt(read, half, rd->proto); } @@ -3446,7 +3446,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, * Erase Types defined in the bfpt table. */ erase_mask = 0; - memset(¶ms->erase_map, 0, sizeof(params->erase_map)); + memset(&flash->erase_map, 0, sizeof(flash->erase_map)); for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) { const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i]; u32 erasesize; @@ -3465,7 +3465,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, spi_nor_set_erase_settings_from_bfpt(&erase_type[i], erasesize, opcode, i); } - spi_nor_init_uniform_erase_map(map, erase_mask, params->size); + spi_nor_init_uniform_erase_map(map, erase_mask, flash->size); /* * Sort all the map's Erase Types in ascending order with the smallest * erase size being the first member in the erase_type array. @@ -3483,43 +3483,42 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, /* Stop here if not JESD216 rev A or later. */ if (bfpt_header->length < BFPT_DWORD_MAX) - return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, - params); + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, flash); /* Page size: this field specifies 'N' so the page size = 2^N bytes. */ - params->page_size = bfpt.dwords[BFPT_DWORD(11)]; - params->page_size &= BFPT_DWORD11_PAGE_SIZE_MASK; - params->page_size >>= BFPT_DWORD11_PAGE_SIZE_SHIFT; - params->page_size = 1U << params->page_size; + flash->page_size = bfpt.dwords[BFPT_DWORD(11)]; + flash->page_size &= BFPT_DWORD11_PAGE_SIZE_MASK; + flash->page_size >>= BFPT_DWORD11_PAGE_SIZE_SHIFT; + flash->page_size = 1U << flash->page_size; /* Quad Enable Requirements. */ switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) { case BFPT_DWORD15_QER_NONE: - params->quad_enable = NULL; + flash->quad_enable = NULL; break; case BFPT_DWORD15_QER_SR2_BIT1_BUGGY: case BFPT_DWORD15_QER_SR2_BIT1_NO_RD: - params->quad_enable = spansion_no_read_cr_quad_enable; + flash->quad_enable = spansion_no_read_cr_quad_enable; break; case BFPT_DWORD15_QER_SR1_BIT6: - params->quad_enable = macronix_quad_enable; + flash->quad_enable = macronix_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT7: - params->quad_enable = sr2_bit7_quad_enable; + flash->quad_enable = sr2_bit7_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT1: - params->quad_enable = spansion_read_cr_quad_enable; + flash->quad_enable = spansion_read_cr_quad_enable; break; default: return -EINVAL; } - return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, flash); } #define SMPT_CMD_ADDRESS_LEN_MASK GENMASK(23, 22) @@ -3721,7 +3720,7 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region, /** * spi_nor_init_non_uniform_erase_map() - initialize the non-uniform erase map * @nor: pointer to a 'struct spi_nor' - * @params: pointer to a duplicate 'struct spi_nor_flash_parameter' that is + * @flash: pointer to a duplicate 'struct spi_nor_flash_parameter' that is * used for storing SFDP parsed data * @smpt: pointer to the sector map parameter table * @@ -3729,10 +3728,10 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region, */ static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, - struct spi_nor_flash_parameter *params, + struct spi_nor_flash_parameter *flash, const u32 *smpt) { - struct spi_nor_erase_map *map = ¶ms->erase_map; + struct spi_nor_erase_map *map = &flash->erase_map; struct spi_nor_erase_type *erase = map->erase_type; struct spi_nor_erase_region *region; u64 offset; @@ -3811,7 +3810,7 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, * spi_nor_parse_smpt() - parse Sector Map Parameter Table * @nor: pointer to a 'struct spi_nor' * @smpt_header: sector map parameter table header - * @params: pointer to a duplicate 'struct spi_nor_flash_parameter' + * @flash: pointer to a duplicate 'struct spi_nor_flash_parameter' * that is used for storing SFDP parsed data * * This table is optional, but when available, we parse it to identify the @@ -3822,7 +3821,7 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, */ static int spi_nor_parse_smpt(struct spi_nor *nor, const struct sfdp_parameter_header *smpt_header, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { const u32 *sector_map; u32 *smpt; @@ -3851,11 +3850,11 @@ static int spi_nor_parse_smpt(struct spi_nor *nor, goto out; } - ret = spi_nor_init_non_uniform_erase_map(nor, params, sector_map); + ret = spi_nor_init_non_uniform_erase_map(nor, flash, sector_map); if (ret) goto out; - spi_nor_regions_sort_erase_types(¶ms->erase_map); + spi_nor_regions_sort_erase_types(&flash->erase_map); /* fall through */ out: kfree(smpt); @@ -3880,13 +3879,13 @@ struct sfdp_4bait { * @nor: pointer to a 'struct spi_nor'. * @param_header: pointer to the 'struct sfdp_parameter_header' describing * the 4-Byte Address Instruction Table length and version. - * @params: pointer to the 'struct spi_nor_flash_parameter' to be. + * @flash: pointer to the 'struct spi_nor_flash_parameter' to be. * * Return: 0 on success, -errno otherwise. */ static int spi_nor_parse_4bait(struct spi_nor *nor, const struct sfdp_parameter_header *param_header, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { static const struct sfdp_4bait reads[] = { { SNOR_HWCAPS_READ, BIT(0) }, @@ -3910,8 +3909,8 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, { 0u /* not used */, BIT(11) }, { 0u /* not used */, BIT(12) }, }; - struct spi_nor_pp_command *params_pp = params->page_programs; - struct spi_nor_erase_map *map = ¶ms->erase_map; + struct spi_nor_pp_command *flash_pp = flash->page_programs; + struct spi_nor_erase_map *map = &flash->erase_map; struct spi_nor_erase_type *erase_type = map->erase_type; u32 *dwords; size_t len; @@ -3949,7 +3948,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, const struct sfdp_4bait *read = &reads[i]; discard_hwcaps |= read->hwcaps; - if ((params->hwcaps.mask & read->hwcaps) && + if ((flash->hwcaps.mask & read->hwcaps) && (dwords[0] & read->supported_bit)) read_hwcaps |= read->hwcaps; } @@ -3965,7 +3964,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, /* * The 4 Byte Address Instruction (Optional) Table is the only * SFDP table that indicates support for Page Program Commands. - * Bypass the params->hwcaps.mask and consider 4BAIT the biggest + * Bypass the flash->hwcaps.mask and consider 4BAIT the biggest * authority for specifying Page Program support. */ discard_hwcaps |= program->hwcaps; @@ -4000,26 +3999,26 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, * Discard all operations from the 4-byte instruction set which are * not supported by this memory. */ - params->hwcaps.mask &= ~discard_hwcaps; - params->hwcaps.mask |= (read_hwcaps | pp_hwcaps); + flash->hwcaps.mask &= ~discard_hwcaps; + flash->hwcaps.mask |= (read_hwcaps | pp_hwcaps); /* Use the 4-byte address instruction set. */ for (i = 0; i < SNOR_CMD_READ_MAX; i++) { - struct spi_nor_read_command *read_cmd = ¶ms->reads[i]; + struct spi_nor_read_command *read_cmd = &flash->reads[i]; read_cmd->opcode = spi_nor_convert_3to4_read(read_cmd->opcode); } /* 4BAIT is the only SFDP table that indicates page program support. */ if (pp_hwcaps & SNOR_HWCAPS_PP) - spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP], + spi_nor_set_pp_settings(&flash_pp[SNOR_CMD_PP], SPINOR_OP_PP_4B, SNOR_PROTO_1_1_1); if (pp_hwcaps & SNOR_HWCAPS_PP_1_1_4) - spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP_1_1_4], + spi_nor_set_pp_settings(&flash_pp[SNOR_CMD_PP_1_1_4], SPINOR_OP_PP_1_1_4_4B, SNOR_PROTO_1_1_4); if (pp_hwcaps & SNOR_HWCAPS_PP_1_4_4) - spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP_1_4_4], + spi_nor_set_pp_settings(&flash_pp[SNOR_CMD_PP_1_4_4], SPINOR_OP_PP_1_4_4_4B, SNOR_PROTO_1_4_4); @@ -4050,7 +4049,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, /** * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters. * @nor: pointer to a 'struct spi_nor' - * @params: pointer to the 'struct spi_nor_flash_parameter' to be + * @flash: pointer to the 'struct spi_nor_flash_parameter' to be * filled * * The Serial Flash Discoverable Parameters are described by the JEDEC JESD216 @@ -4062,7 +4061,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, * Return: 0 on success, -errno otherwise. */ static int spi_nor_parse_sfdp(struct spi_nor *nor, - struct spi_nor_flash_parameter *params) + struct spi_nor_flash_parameter *flash) { const struct sfdp_parameter_header *param_header, *bfpt_header; struct sfdp_parameter_header *param_headers = NULL; @@ -4131,7 +4130,7 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, bfpt_header = param_header; } - err = spi_nor_parse_bfpt(nor, bfpt_header, params); + err = spi_nor_parse_bfpt(nor, bfpt_header, flash); if (err) goto exit; @@ -4141,11 +4140,11 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, switch (SFDP_PARAM_HEADER_ID(param_header)) { case SFDP_SECTOR_MAP_ID: - err = spi_nor_parse_smpt(nor, param_header, params); + err = spi_nor_parse_smpt(nor, param_header, flash); break; case SFDP_4BAIT_ID: - err = spi_nor_parse_4bait(nor, param_header, params); + err = spi_nor_parse_4bait(nor, param_header, flash); break; default: @@ -4183,7 +4182,7 @@ static int spi_nor_select_read(struct spi_nor *nor, if (cmd < 0) return -EINVAL; - read = &nor->params.reads[cmd]; + read = &nor->flash.reads[cmd]; nor->read_opcode = read->opcode; nor->read_proto = read->proto; @@ -4214,7 +4213,7 @@ static int spi_nor_select_pp(struct spi_nor *nor, if (cmd < 0) return -EINVAL; - pp = &nor->params.page_programs[cmd]; + pp = &nor->flash.page_programs[cmd]; nor->program_opcode = pp->opcode; nor->write_proto = pp->proto; return 0; @@ -4275,7 +4274,7 @@ spi_nor_select_uniform_erase(struct spi_nor_erase_map *map, static int spi_nor_select_erase(struct spi_nor *nor) { - struct spi_nor_erase_map *map = &nor->params.erase_map; + struct spi_nor_erase_map *map = &nor->flash.erase_map; const struct spi_nor_erase_type *erase = NULL; struct mtd_info *mtd = &nor->mtd; u32 wanted_size = nor->info->sector_size; @@ -4324,7 +4323,7 @@ static int spi_nor_select_erase(struct spi_nor *nor) static int spi_nor_default_setup(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps) { - struct spi_nor_flash_parameter *params = &nor->params; + struct spi_nor_flash_parameter *flash = &nor->flash; u32 ignored_mask, shared_mask; int err; @@ -4332,7 +4331,7 @@ static int spi_nor_default_setup(struct spi_nor *nor, * Keep only the hardware capabilities supported by both the SPI * controller and the SPI flash memory. */ - shared_mask = hwcaps->mask & params->hwcaps.mask; + shared_mask = hwcaps->mask & flash->hwcaps.mask; if (nor->spimem) { /* @@ -4385,36 +4384,36 @@ static int spi_nor_default_setup(struct spi_nor *nor, static int spi_nor_setup(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps) { - if (!nor->params.setup) + if (!nor->flash.setup) return 0; - return nor->params.setup(nor, hwcaps); + return nor->flash.setup(nor, hwcaps); } static void macronix_set_default_init(struct spi_nor *nor) { - nor->params.quad_enable = macronix_quad_enable; - nor->params.set_4byte = macronix_set_4byte; + nor->flash.quad_enable = macronix_quad_enable; + nor->flash.set_4byte = macronix_set_4byte; } static void st_micron_set_default_init(struct spi_nor *nor) { nor->flags |= SNOR_F_HAS_LOCK; - nor->params.quad_enable = NULL; - nor->params.set_4byte = st_micron_set_4byte; + nor->flash.quad_enable = NULL; + nor->flash.set_4byte = st_micron_set_4byte; } static void winbond_set_default_init(struct spi_nor *nor) { - nor->params.set_4byte = winbond_set_4byte; + nor->flash.set_4byte = winbond_set_4byte; } /** - * spi_nor_manufacturer_init_params() - Initialize the flash's parameters and - * settings based on MFR register and ->default_init() hook. + * spi_nor_manufacturer_init_flash_params() - Initialize the flash's + * parameters and settings based on MFR register and ->default_init() hook. * @nor: pointer to a 'struct spi-nor'. */ -static void spi_nor_manufacturer_init_params(struct spi_nor *nor) +static void spi_nor_manufacturer_init_flash_params(struct spi_nor *nor) { /* Init flash parameters based on MFR */ switch (JEDEC_MFR(nor->info)) { @@ -4440,93 +4439,93 @@ static void spi_nor_manufacturer_init_params(struct spi_nor *nor) } /** - * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings - * based on JESD216 SFDP standard. + * spi_nor_sfdp_init_flash_params() - Initialize the flash's parameters and + * settings based on JESD216 SFDP standard. * @nor: pointer to a 'struct spi-nor'. * * The method has a roll-back mechanism: in case the SFDP parsing fails, the * legacy flash parameters and settings will be restored. */ -static void spi_nor_sfdp_init_params(struct spi_nor *nor) +static void spi_nor_sfdp_init_flash_params(struct spi_nor *nor) { - struct spi_nor_flash_parameter sfdp_params; + struct spi_nor_flash_parameter sfdp_flash; - memcpy(&sfdp_params, &nor->params, sizeof(sfdp_params)); + memcpy(&sfdp_flash, &nor->flash, sizeof(sfdp_flash)); - if (spi_nor_parse_sfdp(nor, &sfdp_params)) { + if (spi_nor_parse_sfdp(nor, &sfdp_flash)) { nor->addr_width = 0; nor->flags &= ~SNOR_F_4B_OPCODES; } else { - memcpy(&nor->params, &sfdp_params, sizeof(nor->params)); + memcpy(&nor->flash, &sfdp_flash, sizeof(nor->flash)); } } /** - * spi_nor_info_init_params() - Initialize the flash's parameters and settings - * based on nor->info data. + * spi_nor_info_init_flash_params() - Initialize the flash's parameters and + * settings based on nor->info data. * @nor: pointer to a 'struct spi-nor'. */ -static void spi_nor_info_init_params(struct spi_nor *nor) +static void spi_nor_info_init_flash_params(struct spi_nor *nor) { - struct spi_nor_flash_parameter *params = &nor->params; - struct spi_nor_erase_map *map = ¶ms->erase_map; + struct spi_nor_flash_parameter *flash = &nor->flash; + struct spi_nor_erase_map *map = &flash->erase_map; const struct flash_info *info = nor->info; struct device_node *np = spi_nor_get_flash_node(nor); u8 i, erase_mask; /* Initialize legacy flash parameters and settings. */ - params->quad_enable = spansion_quad_enable; - params->set_4byte = spansion_set_4byte; - params->setup = spi_nor_default_setup; + flash->quad_enable = spansion_quad_enable; + flash->set_4byte = spansion_set_4byte; + flash->setup = spi_nor_default_setup; /* Set SPI NOR sizes. */ - params->size = (u64)info->sector_size * info->n_sectors; - params->page_size = info->page_size; + flash->size = (u64)info->sector_size * info->n_sectors; + flash->page_size = info->page_size; if (!(info->flags & SPI_NOR_NO_FR)) { /* Default to Fast Read for DT and non-DT platform devices. */ - params->hwcaps.mask |= SNOR_HWCAPS_READ_FAST; + flash->hwcaps.mask |= SNOR_HWCAPS_READ_FAST; /* Mask out Fast Read if not requested at DT instantiation. */ if (np && !of_property_read_bool(np, "m25p,fast-read")) - params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; + flash->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; } /* (Fast) Read settings. */ - params->hwcaps.mask |= SNOR_HWCAPS_READ; - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ], + flash->hwcaps.mask |= SNOR_HWCAPS_READ; + spi_nor_set_read_settings(&flash->reads[SNOR_CMD_READ], 0, 0, SPINOR_OP_READ, SNOR_PROTO_1_1_1); - if (params->hwcaps.mask & SNOR_HWCAPS_READ_FAST) - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_FAST], + if (flash->hwcaps.mask & SNOR_HWCAPS_READ_FAST) + spi_nor_set_read_settings(&flash->reads[SNOR_CMD_READ_FAST], 0, 8, SPINOR_OP_READ_FAST, SNOR_PROTO_1_1_1); if (info->flags & SPI_NOR_DUAL_READ) { - params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2; - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_2], + flash->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2; + spi_nor_set_read_settings(&flash->reads[SNOR_CMD_READ_1_1_2], 0, 8, SPINOR_OP_READ_1_1_2, SNOR_PROTO_1_1_2); } if (info->flags & SPI_NOR_QUAD_READ) { - params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4; - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_4], + flash->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4; + spi_nor_set_read_settings(&flash->reads[SNOR_CMD_READ_1_1_4], 0, 8, SPINOR_OP_READ_1_1_4, SNOR_PROTO_1_1_4); } if (info->flags & SPI_NOR_OCTAL_READ) { - params->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8; - spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_1_1_8], + flash->hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8; + spi_nor_set_read_settings(&flash->reads[SNOR_CMD_READ_1_1_8], 0, 8, SPINOR_OP_READ_1_1_8, SNOR_PROTO_1_1_8); } /* Page Program settings. */ - params->hwcaps.mask |= SNOR_HWCAPS_PP; - spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP], + flash->hwcaps.mask |= SNOR_HWCAPS_PP; + spi_nor_set_pp_settings(&flash->page_programs[SNOR_CMD_PP], SPINOR_OP_PP, SNOR_PROTO_1_1_1); /* @@ -4549,7 +4548,7 @@ static void spi_nor_info_init_params(struct spi_nor *nor) erase_mask |= BIT(i); spi_nor_set_erase_type(&map->erase_type[i], info->sector_size, SPINOR_OP_SE); - spi_nor_init_uniform_erase_map(map, erase_mask, params->size); + spi_nor_init_uniform_erase_map(map, erase_mask, flash->size); } static void spansion_post_sfdp_fixups(struct spi_nor *nor) @@ -4567,7 +4566,7 @@ static void spansion_post_sfdp_fixups(struct spi_nor *nor) static void s3an_post_sfdp_fixups(struct spi_nor *nor) { - nor->params.setup = s3an_nor_setup; + nor->flash.setup = s3an_nor_setup; } /** @@ -4599,24 +4598,25 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) } /** - * spi_nor_late_init_params() - Late initialization of default flash parameters. + * spi_nor_late_init_flash_params() - Late initialization of default flash + * parameters. * @nor: pointer to a 'struct spi_nor' * * Used to set default flash parameters and settings when the ->default_init() * hook or the SFDP parser let voids. */ -static void spi_nor_late_init_params(struct spi_nor *nor) +static void spi_nor_late_init_flash_params(struct spi_nor *nor) { /* * NOR protection support. When locking_ops are not provided, we pick * the default ones. */ - if (nor->flags & SNOR_F_HAS_LOCK && !nor->params.locking_ops) - nor->params.locking_ops = &stm_locking_ops; + if (nor->flags & SNOR_F_HAS_LOCK && !nor->flash.locking_ops) + nor->flash.locking_ops = &stm_locking_ops; } /** - * spi_nor_init_params() - Initialize the flash's parameters and settings. + * spi_nor_init_flash_params() - Initialize the flash's parameters and settings. * @nor: pointer to a 'struct spi-nor'. * * The flash parameters and settings are initialized based on a sequence of @@ -4624,18 +4624,18 @@ static void spi_nor_late_init_params(struct spi_nor *nor) * * 1/ Default flash parameters initialization. The initializations are done * based on nor->info data: - * spi_nor_info_init_params() + * spi_nor_info_init_flash_params() * * which can be overwritten by: * 2/ Manufacturer flash parameters initialization. The initializations are * done based on MFR register, or when the decisions can not be done solely * based on MFR, by using specific flash_info tweeks, ->default_init(): - * spi_nor_manufacturer_init_params() + * spi_nor_manufacturer_init_flash_params() * * which can be overwritten by: * 3/ SFDP flash parameters initialization. JESD216 SFDP is a standard and * should be more accurate that the above. - * spi_nor_sfdp_init_params() + * spi_nor_sfdp_init_flash_params() * * Please note that there is a ->post_bfpt() fixup hook that can overwrite * the flash parameters and settings immediately after parsing the Basic @@ -4649,22 +4649,22 @@ static void spi_nor_late_init_params(struct spi_nor *nor) * spi_nor_post_sfdp_fixups() * * 5/ Late default flash parameters initialization, used when the - * ->default_init() hook or the SFDP parser do not set specific params. - * spi_nor_late_init_params() + * ->default_init() hook or the SFDP parser do not set specific flash params. + * spi_nor_late_init_flash_params() */ -static void spi_nor_init_params(struct spi_nor *nor) +static void spi_nor_init_flash_params(struct spi_nor *nor) { - spi_nor_info_init_params(nor); + spi_nor_info_init_flash_params(nor); - spi_nor_manufacturer_init_params(nor); + spi_nor_manufacturer_init_flash_params(nor); if ((nor->info->flags & (SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)) && !(nor->info->flags & SPI_NOR_SKIP_SFDP)) - spi_nor_sfdp_init_params(nor); + spi_nor_sfdp_init_flash_params(nor); spi_nor_post_sfdp_fixups(nor); - spi_nor_late_init_params(nor); + spi_nor_late_init_flash_params(nor); } /** @@ -4675,14 +4675,14 @@ static void spi_nor_init_params(struct spi_nor *nor) */ static int spi_nor_quad_enable(struct spi_nor *nor) { - if (!nor->params.quad_enable) + if (!nor->flash.quad_enable) return 0; if (!(spi_nor_get_protocol_width(nor->read_proto) == 4 || spi_nor_get_protocol_width(nor->write_proto) == 4)) return 0; - return nor->params.quad_enable(nor); + return nor->flash.quad_enable(nor); } static int spi_nor_init(struct spi_nor *nor) @@ -4690,7 +4690,7 @@ static int spi_nor_init(struct spi_nor *nor) int err; if (nor->clear_sr_bp) { - if (nor->params.quad_enable == spansion_quad_enable) + if (nor->flash.quad_enable == spansion_quad_enable) nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp; err = nor->clear_sr_bp(nor); @@ -4717,7 +4717,7 @@ static int spi_nor_init(struct spi_nor *nor) */ WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, "enabling reset hack; may not recover from unexpected reboots\n"); - nor->params.set_4byte(nor, true); + nor->flash.set_4byte(nor, true); } return 0; @@ -4741,7 +4741,7 @@ void spi_nor_restore(struct spi_nor *nor) /* restore the addressing mode */ if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES) && nor->flags & SNOR_F_BROKEN_RESET) - nor->params.set_4byte(nor, false); + nor->flash.set_4byte(nor, false); } EXPORT_SYMBOL_GPL(spi_nor_restore); @@ -4841,7 +4841,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, struct device *dev = nor->dev; struct mtd_info *mtd = &nor->mtd; struct device_node *np = spi_nor_get_flash_node(nor); - struct spi_nor_flash_parameter *params = &nor->params; + struct spi_nor_flash_parameter *flash = &nor->flash; int ret; int i; @@ -4900,7 +4900,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->clear_sr_bp = spi_nor_clear_sr_bp; /* Init flash parameters based on flash_info struct and SFDP */ - spi_nor_init_params(nor); + spi_nor_init_flash_params(nor); if (!mtd->name) mtd->name = dev_name(dev); @@ -4908,12 +4908,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, mtd->type = MTD_NORFLASH; mtd->writesize = 1; mtd->flags = MTD_CAP_NORFLASH; - mtd->size = params->size; + mtd->size = flash->size; mtd->_erase = spi_nor_erase; mtd->_read = spi_nor_read; mtd->_resume = spi_nor_resume; - if (nor->params.locking_ops) { + if (nor->flash.locking_ops) { mtd->_lock = spi_nor_lock; mtd->_unlock = spi_nor_unlock; mtd->_is_locked = spi_nor_is_locked; @@ -4938,7 +4938,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, mtd->flags |= MTD_NO_ERASE; mtd->dev.parent = dev; - nor->page_size = params->page_size; + nor->page_size = flash->page_size; mtd->writebufsize = nor->page_size; if (of_property_read_bool(np, "broken-flash-reset")) diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index d1d736d3c8ab..12961b157743 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -580,10 +580,10 @@ struct flash_info; * @controller_ops: SPI NOR controller driver specific operations. * @clear_sr_bp: [FLASH-SPECIFIC] clears the Block Protection Bits from * the SPI NOR Status Register. - * @params: [FLASH-SPECIFIC] SPI-NOR flash parameters and settings. - * The structure includes legacy flash parameters and - * settings that can be overwritten by the spi_nor_fixups - * hooks, or dynamically when parsing the SFDP tables. + * @flash: SPI-NOR flash parameters and settings. The structure + * includes default flash parameters and settings that can + * be overwritten by the spi_nor_fixups hooks, or + * dynamically when parsing the SFDP tables. * @priv: the private data */ struct spi_nor { @@ -609,7 +609,7 @@ struct spi_nor { const struct spi_nor_controller_ops *controller_ops; int (*clear_sr_bp)(struct spi_nor *nor); - struct spi_nor_flash_parameter params; + struct spi_nor_flash_parameter flash; void *priv; }; @@ -640,7 +640,7 @@ spi_nor_region_mark_overlay(struct spi_nor_erase_region *region) static bool __maybe_unused spi_nor_has_uniform_erase(const struct spi_nor *nor) { - return !!nor->params.erase_map.uniform_erase_type; + return !!nor->flash.erase_map.uniform_erase_type; } static inline void spi_nor_set_flash_node(struct spi_nor *nor, From patchwork Tue Sep 17 15:54:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CE4A112B for ; Tue, 17 Sep 2019 15:59:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15FF42171F for ; Tue, 17 Sep 2019 15:59:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rCAfUVHV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="gX/cBEgR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15FF42171F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=2eGa52Kn0zRuRZa9JCWmlih319fKOEw3bgxBBSXpJFw=; b=rCAfUVHVvAAREs OrBaqdVqPdfzmI983IMd58sib0230k4tfrM0N0MZWwyEvbOHBkygjV3ZWEUw4Gkrv4yn/GzAWHGIo 4Xdq2RwywdzD3BmgNUpMthziPCXO7d7hrDmtbC5fQbzSH+X4sb4LNAqwv9vcO06rzmQ0AsF8wlhML ugwV2ZLtXR1VgnrIsShXgjhJW7TbB76UtaZAt+d6mIYhJk17nc3crUGkB7vg9syPIQZRYOlnKaF9j z21aopB2OC9s5wrEfyWvRFWdvXJBDXo5bWqaaEhlVpVzxIHunZ2ov+ASaG3b9VUH9wae/2JNdSbp9 0Q6rzM78dKgly2Wkd+rA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFsl-0001zF-8D; Tue, 17 Sep 2019 15:59:11 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFoo-0006wH-OT; Tue, 17 Sep 2019 15:55:09 +0000 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: d+Nc2Rulb06OY5N7NaceS0zZVULDyE7EJlRxgqq5CNd9m9vjQvJhz1gT6AMfOVCqBwcq2T98nO C6mMu+xB98BWUXDMCpdnPFr33HRn7P8zHKO2P1nrJ7s011wyt+xJnn3CRCWNqnDgorhU5ZcVpG 7l2a5/6EUPzQiD2ci1MjOCUaLL1ZP5PUOFex068HSkeAJuKzLI4gWlv+hO4x8cDCJP3wRXi4IC jYiu3n1T1F11QOFF1LX8LeYT5chjzz3pdC3WLS+A6w4EZ7jpzecSoiVY1Ae+ApkbqYLtB2EWCV ECw= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="46517547" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:54:59 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:54:59 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:54:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cqQxZTmibgPsTNpRC+v4ZVVqC1BLxY4Qr/HBulqkOXCIcWruACJyQzlrIN+jptTUIfMe+qDSuVwMZ8L7bnkmcTaBVjH6untAvZoZ3DFIrhrA0rlztVGgf+KMoWK5SkJ48t0C5MyusToW3cTgdDcoyc9GvX71nBKm+IgtEnoA2GYBRwbnGYQzXV6viaf3Ru1dlkTMRh7se44ws4+oasmCKJVNDqYBOmIAywFnPjNs2xSyC+jC+eBnqLKKqJMR880+aWrLRIW5aaETNdT+zY+DY6SXc34tMQsKycg8HdjOg6pYjRsJKAWbyBGUbwBSCVUL0994JLan/yGuV1glQRZFpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8VDCyvHSOv9P80Ue/P+4wVsE5m6IE5589YJSUDfOwAU=; b=FrmjbVxsTw26e+PUqgF0JffkiJ8zCqJwjP6stmPYFTDL2Zns1kGT8j9HHOMRGHPQCEJ8yLqBuZNqPvSwN1+dScQ+u5shzsn+uVJElMmWU5ZL0rg3rEAS4yUK4JgU5XN4773EbASlgc53m1ppp9rcC1QdReoOnl6Bz2v+cHq4RUpjYyPsvyZ3SInp5e9lHqV3pKnrdKYMO+O2VPZPHWU8dLPJXwHGDcgrslnuK/Aqxpz/CR2+A0O+jzERPKb2DBe5jtFBO5T0hpQQKpSZbp8ZiDu/i7qZIpXC/Mjn3M7jX69f7HA95klzO0Fbyl+kZflC8shddcHDWnkYDFqJ4qTUEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8VDCyvHSOv9P80Ue/P+4wVsE5m6IE5589YJSUDfOwAU=; b=gX/cBEgRaidi1JUtFuD3tsoroAyCifHGDAoc48Rh+v+yAwglAGLzYYGd55RmKmRve4P1WruMg0AT+UL+goj4igvMbVJrvyf8awK/EjYasSaXkWSzy0/aSGNAo9Zq8BbxiOw/bKJ8pB8bxkJxvzngCZKGZ8B4Sms2nKtFjwUn12s= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:54:57 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:54:57 +0000 From: To: , , , , , Subject: [PATCH 05/23] mtd: spi-nor: Rework read_sr() Thread-Topic: [PATCH 05/23] mtd: spi-nor: Rework read_sr() Thread-Index: AQHVbXBAM2cW12dHpUWRC4uQkzuNdQ== Date: Tue, 17 Sep 2019 15:54:56 +0000 Message-ID: <20190917155426.7432-6-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1046d67f-ebe4-4dd8-e2f6-08d73b87632f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: U22JuMRKgU73ZILGx11OeUIc+4mI3v6G5f7Uf68oN+X5/3sTo/rMPyHa74yE8dQzbCiuJvxlpPK2m2ucJYaHNjY7ycXi1rogPHcwjbJD8eu+efCopyGCjPSytkyDbGz2AGFdshcRLDASy4IivZ/V6OA9Mhin9ojs6X9BYxoo38ATyTDc8PnG01hZugRXpSABE/xqOq0bSJV6gei+Cqb9ef417Bl+1u+Nz2BkKU5As89HFwtuoxg5s82jtMC6a8FfK157CVOtLghJvdYMfVKVu4QrSB1QiETEDyP0uxMo54v1BwtBnnKg6AcXt46JNJkl/WdaCxEGri5D1qFnwg/EysqmrNZdJmABi4Bsbg6oBTF3pe7Zc1tG7YDhYIhIRsTxUNwaaNZrfYodOGmDa7mGVQPcGe7ljTnMwpT0AKKrXmM= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1046d67f-ebe4-4dd8-e2f6-08d73b87632f X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:54:56.9759 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OWpRo6XhAfaj5ejm4OyB1orL3mnzz5Zf54NBCKwgP6djyQ04yV3SvnUGS3XFPQoWn6Bl9m92ulE8hOYcdAiIRmDXuswBaRJOAxT8D9SCUjE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085507_166465_23483487 X-CRM114-Status: GOOD ( 14.98 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus static int read_sr(struct spi_nor *nor) becomes static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) The new function returns 0 on success and -errno otherwise. We let the callers pass the pointer to the buffer where the value of the Status Register will be written. This way we avoid the casts between int and u8, which can be confusing. Prepend spi_nor_ to the function name, all functions should begin with that. S/pr_err/dev_err and drop duplicated dev_err in callers, in case the function returns error. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 131 +++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 66 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 7d0c1b598250..a23783641146 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -388,12 +388,14 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, return nor->controller_ops->write(nor, to, len, buf); } -/* - * Read the status register, returning its value in the location - * Return the status register value. - * Returns negative if error occurred. +/** + * spi_nor_read_sr() - Read the Status Register. + * @nor: pointer to 'struct spi_nor' + * @sr: buffer where the value of the Status Register will be written. + * + * Return: 0 on success, -errno otherwise. */ -static int read_sr(struct spi_nor *nor) +static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) { int ret; @@ -402,20 +404,17 @@ static int read_sr(struct spi_nor *nor) SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR, 1), SPI_MEM_OP_NO_ADDR, SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1)); + SPI_MEM_OP_DATA_IN(1, sr, 1)); ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, - nor->bouncebuf, 1); + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, sr, 1); } - if (ret < 0) { - pr_err("error %d reading SR\n", (int) ret); - return ret; - } + if (ret) + dev_err(nor->dev, "error %d reading SR\n", ret); - return nor->bouncebuf[0]; + return ret; } /* @@ -752,12 +751,14 @@ static int spi_nor_clear_sr(struct spi_nor *nor) static int spi_nor_sr_ready(struct spi_nor *nor) { - int sr = read_sr(nor); - if (sr < 0) - return sr; + int ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + + if (ret) + return ret; - if (nor->flags & SNOR_F_USE_CLSR && sr & (SR_E_ERR | SR_P_ERR)) { - if (sr & SR_E_ERR) + if (nor->flags & SNOR_F_USE_CLSR && + nor->bouncebuf[0] & (SR_E_ERR | SR_P_ERR)) { + if (nor->bouncebuf[0] & SR_E_ERR) dev_err(nor->dev, "Erase Error occurred\n"); else dev_err(nor->dev, "Programming Error occurred\n"); @@ -766,7 +767,7 @@ static int spi_nor_sr_ready(struct spi_nor *nor) return -EIO; } - return !(sr & SR_WIP); + return !(nor->bouncebuf[0] & SR_WIP); } static int spi_nor_clear_fsr(struct spi_nor *nor) @@ -1341,11 +1342,11 @@ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) if (ret) return ret; - ret = read_sr(nor); - if (ret < 0) + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) return ret; - return ((ret & mask) != (status_new & mask)) ? -EIO : 0; + return ((nor->bouncebuf[0] & mask) != (status_new & mask)) ? -EIO : 0; } static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, @@ -1440,16 +1441,18 @@ static int stm_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) { struct mtd_info *mtd = &nor->mtd; - int status_old, status_new; + int ret, status_old, status_new; u8 mask = SR_BP2 | SR_BP1 | SR_BP0; u8 shift = ffs(mask) - 1, pow, val; loff_t lock_len; bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB; bool use_top; - status_old = read_sr(nor); - if (status_old < 0) - return status_old; + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; + + status_old = nor->bouncebuf[0]; /* If nothing in our range is unlocked, we don't need to do anything */ if (stm_is_locked_sr(nor, ofs, len, status_old)) @@ -1520,16 +1523,18 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) { struct mtd_info *mtd = &nor->mtd; - int status_old, status_new; + int ret, status_old, status_new; u8 mask = SR_BP2 | SR_BP1 | SR_BP0; u8 shift = ffs(mask) - 1, pow, val; loff_t lock_len; bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB; bool use_top; - status_old = read_sr(nor); - if (status_old < 0) - return status_old; + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; + + status_old = nor->bouncebuf[0]; /* If nothing in our range is locked, we don't need to do anything */ if (stm_is_unlocked_sr(nor, ofs, len, status_old)) @@ -1604,13 +1609,12 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) */ static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) { - int status; + int ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); - status = read_sr(nor); - if (status < 0) - return status; + if (ret) + return ret; - return stm_is_locked_sr(nor, ofs, len, status); + return stm_is_locked_sr(nor, ofs, len, nor->bouncebuf[0]); } static const struct spi_nor_locking_ops stm_locking_ops = { @@ -1717,24 +1721,28 @@ static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) */ static int macronix_quad_enable(struct spi_nor *nor) { - int ret, val; + int ret; - val = read_sr(nor); - if (val < 0) - return val; - if (val & SR_QUAD_EN_MX) + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; + + if (nor->bouncebuf[0] & SR_QUAD_EN_MX) return 0; write_enable(nor); - write_sr(nor, val | SR_QUAD_EN_MX); + write_sr(nor, nor->bouncebuf[0] | SR_QUAD_EN_MX); ret = spi_nor_wait_till_ready(nor); if (ret) return ret; - ret = read_sr(nor); - if (!(ret > 0 && (ret & SR_QUAD_EN_MX))) { + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; + + if (!(nor->bouncebuf[0] & SR_QUAD_EN_MX)) { dev_err(nor->dev, "Macronix Quad bit not set\n"); return -EINVAL; } @@ -1805,12 +1813,10 @@ static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) int ret; /* Keep the current value of the Status Register. */ - ret = read_sr(nor); - if (ret < 0) { - dev_err(nor->dev, "error while reading status register\n"); - return -EINVAL; - } - sr_cr[0] = ret; + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) + return ret; + sr_cr[1] = CR_QUAD_EN_SPAN; return write_sr_cr(nor, sr_cr); @@ -1848,12 +1854,9 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) sr_cr[1] = ret | CR_QUAD_EN_SPAN; /* Keep the current value of the Status Register. */ - ret = read_sr(nor); - if (ret < 0) { - dev_err(dev, "error while reading status register\n"); - return -EINVAL; - } - sr_cr[0] = ret; + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) + return ret; ret = write_sr_cr(nor, sr_cr); if (ret) @@ -1964,15 +1967,13 @@ static int spi_nor_clear_sr_bp(struct spi_nor *nor) int ret; u8 mask = SR_BP2 | SR_BP1 | SR_BP0; - ret = read_sr(nor); - if (ret < 0) { - dev_err(nor->dev, "error while reading status register\n"); + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) return ret; - } write_enable(nor); - ret = write_sr(nor, ret & ~mask); + ret = write_sr(nor, nor->bouncebuf[0] & ~mask); if (ret) { dev_err(nor->dev, "write to status register failed\n"); return ret; @@ -2018,13 +2019,11 @@ static int spi_nor_spansion_clear_sr_bp(struct spi_nor *nor) if (ret & CR_QUAD_EN_SPAN) { sr_cr[1] = ret; - ret = read_sr(nor); - if (ret < 0) { - dev_err(nor->dev, - "error while reading status register\n"); + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) return ret; - } - sr_cr[0] = ret & ~mask; + + sr_cr[0] &= ~mask; ret = write_sr_cr(nor, sr_cr); if (ret) From patchwork Tue Sep 17 15:55:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5227C912 for ; Tue, 17 Sep 2019 16:00:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27B0A214AF for ; Tue, 17 Sep 2019 16:00:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NTVRnjuP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="OWM08L81" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27B0A214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=i7nmN0zaBiZeZj76w51fXaKbCg810EHapgbNCqL6poA=; b=NTVRnjuPKAO4vY Cw0vCiJjDVbYs7WBR/TKkmHjgNfBhQkTMlYZAizTjLYhkGONvnC+80etWTyaCd4OALsGdt+iYRNeD HEH2Dl/pjCLanH2ajLpKh9ZR9KA12WfKR+8mFnXR1GxK1viAisRi57K8pjqjoChM1A560XKeoh7kI pSaGblwR/rcyk2LGXj8pAgjKrxbd6LxRl5NCuyXS+UpHtXWM/YT6zIfJyRsu0ZVOxdOzjJFSvChNC mp5DXEDTM7l9Jly4MhySuBKCdsmNstmx9PAVKWEv0cwErCKP83Hqp1KeKPT2HeTn1YwQUlKq5ILE8 P+9NPCMRbksNGlzAAmyQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFtu-0004Da-Kv; Tue, 17 Sep 2019 16:00:22 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFot-0007aH-JP; Tue, 17 Sep 2019 15:55:13 +0000 Received-SPF: Pass (esa2.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa2.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa2.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: 3Z57Bu8UTv+Ml8uRNFkSFKX1hOJbiYbcC9uJtvkm4qhqLhO4xWUqq2NZb1P3ys/Qz5sf3QP+KX k41AenvOUHy6bIimapLcv4Ddce9/3thuXvS/hAcuZUDISPZM1Ky/DDbH2eoOUbv/OIjhPaeeqz VH1EEIfn0m67UnDghK8CTCrbfQwZuYsk0QDbHaFOoCh72uuhg2muFXHwGAfZduqNxGLi061TuQ pOM5j78nhxYK25RD+K9zYdOlGbQgK0NkcfMO1En1sfhysbtAyCM9ekOeERXCn0ODH7V/EQY4Ma 5s0= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="49242944" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:08 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:01 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l3bsKaMteenHBAP4LNvSLkz4cz2HwtfIX80AhnSbRxmisDiTfxNdkZCssAW47nlExeOgfFS4bV0t4u1nKnGE8e8JpW2acF4BFoBjmZrIqPgPvijo9+yP8Fbu5EXU+f24iurTyosoLdwoPfMdVIHLBT3/ts1SntDJGPMDJ/r/T59a2gj8Pter2jl3L3ZkwXzVlMKWnuddmagQjOg0w/uhqCLML2DxrCaLcKLkE3D+uGPN7OaPn5DS2cf7MTKk1kRwqGgXuYLbBqG35x3PTGYpMsXzDK0eBmfsTzrTsTI2iZCUh+Tik/i7zdpxe72acFHHmYd1Ubpza+WBoIqTwrA8QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ah4m8qbOplFVF1mTbFMxOSWfMYHHblFYFN2vdDu33cU=; b=amSEE1+uXp57M2LCX4VHlcy9XoSMVdhxObb6tCpC7OPgtrQDXJPQwUNNdfA71DVB1Nkjxj8VIf78ZvROIZYGaF5Oyt9H0TZVjvQKxUQI9JcsW7w6gVxCvtL4Uw+N0YVI2KTmYvniWhoYET1RA8Ktud7t9b3d9NDxErYJme7nMjsCs3vnYhNRM9ha4ispDiXNpvvKlAg9ly1c/9HbviKd7FtyyJgMPHN4LRALRpuKPl6MdmladoX+p+JQWkL6tjVKQG1wG3Vdxs2XyLkAMIYoIN22jiqaECvO3+H41jAoLwWRwucbrfB70S3K/IJ60oAcEsqqo4jL52C1cXgVZus7UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ah4m8qbOplFVF1mTbFMxOSWfMYHHblFYFN2vdDu33cU=; b=OWM08L81N9zeI8EdsRMbv45cFk4jWAv13kYYemHfztnqQ73TXEbe72QEZdkGQ5qsAJggp/B+IQ+E0tFIOtHAu6A7xNy45ZUyK4AzA2CDmCxIxyWyx8FX9G+WZP3K4yrHcyCbE3av6Qilsu1svWHsWl+xJL1Pr02QHcRy6Wk5w2o= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:00 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:00 +0000 From: To: , , , , , Subject: [PATCH 06/23] mtd: spi-nor: Rework read_fsr() Thread-Topic: [PATCH 06/23] mtd: spi-nor: Rework read_fsr() Thread-Index: AQHVbXBCAd7k1V0ru0G6ltE9Ea1m4w== Date: Tue, 17 Sep 2019 15:55:00 +0000 Message-ID: <20190917155426.7432-7-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c213c8ff-79c9-4933-2340-08d73b876515 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: zhBot36dsRi5CDM0i+aCqZynPnyv641XjVJPHZBtEQbs0ZROAEONwvwhuFTp/ODLdTdcNENgHpQb0Y+zWbv9gJEkRc1GhuWzNZoDEugEnukt306L7PuvnzM4nFXYvNvBJn8EjifNyH61tzKK6Wzoq5OnbdhJ09+FjBO4xpGZ9qF1fOOStuqA2MRrgAAdCL31uufYmey5JYLR6Gp8pfNY3Bvjlz2J6XYWAUmYWNEVtJTFyCUytd/m+ZJtbG37gyK/4iyQQFomNkWQTP0hMERjm/CTQwRzFCPjJ8aghE8sbEoEqVgxm6iyWMIdvLchB1ggbm0oyIjLqSSD2IFJ+e4z91BSnloKQQboksBdVcwXzmz8Kj+ZgCLSgE4MXP6iKrDylgiIRt8pOtx0uhxUHTPXuIp+ykdp779lI5HF1eYRPjY= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: c213c8ff-79c9-4933-2340-08d73b876515 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:00.2240 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: eq3Fl2VSq8vBoM2ccD+XHbBG3DJKouDvTs7bnVtM2WLndIMjFqZU9V4MVdus0QhiVb8SEGXRmaellZ1VBcBL/f16OJDI2Dt78WTOp7pt4mc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085511_725628_6DCEFD82 X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.149.84 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus static int read_fsr(struct spi_nor *nor) becomes static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) The new function returns 0 on success and -errno otherwise. We let the callers pass the pointer to the buffer where the value of the Flag Status Register will be written. This way we avoid the casts between int and u8, which can be confusing. Prepend spi_nor_ to the function name, all functions should begin with that. S/pr_err/dev_err and drop duplicated dev_err in callers, in case the function returns error. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index a23783641146..8cd1cadcb8b1 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -417,12 +417,15 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) return ret; } -/* - * Read the flag status register, returning its value in the location - * Return the status register value. - * Returns negative if error occurred. +/** + * spi_nor_read_fsr() - Read the Flag Status Register. + * @nor: pointer to 'struct spi_nor' + * @fsr: buffer where the value of the Flag Status Register will be + * written. + * + * Return: 0 on success, -errno otherwise. */ -static int read_fsr(struct spi_nor *nor) +static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) { int ret; @@ -431,20 +434,18 @@ static int read_fsr(struct spi_nor *nor) SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDFSR, 1), SPI_MEM_OP_NO_ADDR, SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1)); + SPI_MEM_OP_DATA_IN(1, fsr, 1)); ret = spi_mem_exec_op(nor->spimem, &op); } else { ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDFSR, - nor->bouncebuf, 1); + fsr, 1); } - if (ret < 0) { - pr_err("error %d reading FSR\n", ret); - return ret; - } + if (ret) + dev_err(nor->dev, "error %d reading FSR\n", ret); - return nor->bouncebuf[0]; + return ret; } /* @@ -787,25 +788,26 @@ static int spi_nor_clear_fsr(struct spi_nor *nor) static int spi_nor_fsr_ready(struct spi_nor *nor) { - int fsr = read_fsr(nor); - if (fsr < 0) - return fsr; + int ret = spi_nor_read_fsr(nor, &nor->bouncebuf[0]); + + if (ret) + return ret; - if (fsr & (FSR_E_ERR | FSR_P_ERR)) { - if (fsr & FSR_E_ERR) + if (nor->bouncebuf[0] & (FSR_E_ERR | FSR_P_ERR)) { + if (nor->bouncebuf[0] & FSR_E_ERR) dev_err(nor->dev, "Erase operation failed.\n"); else dev_err(nor->dev, "Program operation failed.\n"); - if (fsr & FSR_PT_ERR) + if (nor->bouncebuf[0] & FSR_PT_ERR) dev_err(nor->dev, - "Attempted to modify a protected sector.\n"); + "Attempted to modify a protected sector.\n"); spi_nor_clear_fsr(nor); return -EIO; } - return fsr & FSR_READY; + return nor->bouncebuf[0] & FSR_READY; } static int spi_nor_ready(struct spi_nor *nor) From patchwork Tue Sep 17 15:55:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149051 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DB3F1708 for ; Tue, 17 Sep 2019 15:59:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 589CF214AF for ; Tue, 17 Sep 2019 15:59:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="r1xo37V4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="kC/pNPrq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 589CF214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=0d2+bPlQXLy0QgLKl9czU4hfTujv2RpN8uvncHk2sJg=; b=r1xo37V4V3WIDy /p3XGz1+BnpDn4XM9PWgQaycC3Na5oIDDWEfTT1qz3fvNupX2OybXSM1PkroKWEAhJPuu5HVLfpdT 5Ss0DPTqBP6kFbt5yCSsjBAsubfkKWqf4M8b/6vWErIxWSPqxo9ShBOnYWJSRlhpGgqmLi1FcnELL 2SIFlUYK81ysQuGHBreDeMG6Cik3xNv/UkVSmSkzgayI1GqtjTeY/cBcsvSNlMCecHpow6xO1+pxw AUg0cfW8Cse8rxW7hQyBBdxNsZPsibJQGzHbRHn/pF2Ci4S5sFBvpI359jV78HJBlBoTEboGvbWJd AMW3uzio44Azi0woIMqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFtW-0002jb-UN; Tue, 17 Sep 2019 15:59:59 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFot-0006wH-Fh; Tue, 17 Sep 2019 15:55:13 +0000 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: VqI5gCWCb+EpMZCko32/34CPWGMKY49niamTZgFsDDgHSOqnG60QkBXfrkeyNdrwm7Fpf2JpLI l5A2t3hCyWLykmpEuJ2/FwkyHUHdTo+vC6thPXVVBF1VxohZyeKVZKpd4QBM1fFs2lQqz70Ka/ XUG31Ej00v3bHTRlw/uSlIZF2p7iqXcKtq2lIIRC27ob4KD02SHgVJdfN6LtfdWdK7JdiU94yr a0iWOewUVTMDK/e0sSOYTPG5M/diVVLhCjzkP93TUJwQu+trU3L2wC8BrjzHQTFlUdP1D7okCX PSI= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="46517662" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:09 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:05 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QRPaKBUCyH22e0ZMYZ81etooLJF+DAGJtxRIRGgoMqHavpCJudbEeGXZp7nqOpw2+bXGWWugtIs61MWMqtCZFiRPlwAH6dJDYaOnDT3hOAk5nLHVcabuTX9TM6toNOvPl4AGR2vtIStSrc70QKdjdvXLXq3FJCY2JZrrwAZhHdQAjRrxWmQqdr3RpzinMYRJOmsu5UpZNrmbi9tl52dxei6VJI+qacyHqT6qmT9I+RFu+44DAxtGtLiTrrt3Sw6+oC6WrLZ38hQFXi93L2MVpC7Cg+M+CEc+xpw/2EnLAqi0X1GIX2BPShG1ZZqsbOWRi3KoDyIaYBC1riscE5p36g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OBKhUz7wCD4+xga3q7ImeAcsWiyA8JLz2CJsngeUTIE=; b=bE4AmCmNOcso8AoZ30GIDD4NWAkHU64C+VGYwSi6JG1jV3fa/6pz/GX4goe9+1IFGxC3luftgLrQYX/cnhSE+YXg7gNVUj8BohUg+IGtRX7LyjSOzd+qgkCoiAXUZa/i9v2awzMfQOMtvCVEE2A2eTnhjeQwY0Tx9r3fOFZlbeV9J3Fo0P3AOv6xPnZbYDT9+h/cv+xkFxLoM3z/ACxgHKKpOLOMZbhxIyzFqU5PWsIcWnd9QkgFMoEXD5InLEbQJSmR6oteMQcFB7brAtrrDR4FgrnsZjUCUoJBm+zGP/vK1e+I2NrrPJtn5REfySpTGE2uSYRFQfatZEbRBUSsfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OBKhUz7wCD4+xga3q7ImeAcsWiyA8JLz2CJsngeUTIE=; b=kC/pNPrqdi3BqiJ9xg8ore/xp8bk4+4eddsjeG6cemvO9SNZ1QQbC0oi7HuquzTB/MTR6R8kmpEtm7fAhcnq4U6Y1SPyooqqq/1KcHtp3OAu5sooC4deIqLDxX4Z1gbxmjnOxj4LY9UxiOVIqsVGE1277WYCgOueU/KBpnJ2a34= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:03 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:03 +0000 From: To: , , , , , Subject: [PATCH 07/23] mtd: spi-nor: Rework read_cr() Thread-Topic: [PATCH 07/23] mtd: spi-nor: Rework read_cr() Thread-Index: AQHVbXBEW9QaD53790O90YS1lx9Xog== Date: Tue, 17 Sep 2019 15:55:03 +0000 Message-ID: <20190917155426.7432-8-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dc2c6571-838e-47a9-ee72-08d73b8766f9 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 71KEGZ62Tga/h0Wuo9nVRUGsTofImqScKCGTQL1wEerrL1hTh63u+KVBHOWz2c49gWGwTON/TtUTD/S0QN/DZsB5Ak49CFEXBBgNlHkkwAlQkt79oKYyGHkHVr/RGI4+JnODGiLNY9LbfInMTiZfqXVg2hmV2ftolUAzEQQgHiVDEkeilOc55I+3nQ9s0oOoJgbvhq2lBqcD1WnbGEicUBtxTns4Sjq0D/DxPg4hzbOudj8TdqL7NXN29sKI8x1IsTbKpfodlzc09vmF1FdRKhQSVSyMRDvzexeVlwSGxDuAW64DG6aLv8kIDJjg+3aDOBp4Ki0O+gXi3Gvd4dnze41EGMnwL94fK6v83S9DyA7zncDDkAykViRznGaDP9ACG5xEHCn1bfk8LAW0CLEQg/tIMFcZrz/4++vgfMe0daA= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: dc2c6571-838e-47a9-ee72-08d73b8766f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:03.3591 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: AfUG+3+ZAo30mtEF2Tf+LnndtTUvUvlAttLO2fYM4h3sgEAL7fl6u4mhY6PeR/kENtj90uTsyktKz/kCA++oULgASicwt/XhXrhcokzuk+I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085511_726214_9DD5DABA X-CRM114-Status: GOOD ( 14.88 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus static int read_cr(struct spi_nor *nor) becomes static int spi_nor_read_cr(struct spi_nor *nor, u8 *cr) The new function returns 0 on success and -errno otherwise. We let the callers pass the pointer to the buffer where the value of the Configuration Register will be written. This way we avoid the casts between int and u8, which can be confusing. Prepend spi_nor_ to the function name, all functions should begin with that. Vendors are using both the "Configuration Register" and the "Status Register 2" terminology when referring to the second byte of the Status Register. Indicate in the description of the function that we use the SPINOR_OP_RDCR (35h) command to interrogate the Configuration Register. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 66 +++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 8cd1cadcb8b1..04491885b9bb 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -448,12 +448,16 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) return ret; } -/* - * Read configuration register, returning its value in the - * location. Return the configuration register value. - * Returns negative if error occurred. +/** + * spi_nor_read_cr() - Read the Configuration Register using the + * SPINOR_OP_RDCR (35h) command. + * @nor: pointer to 'struct spi_nor' + * @fsr: buffer where the value of the Configuration Register + * will be written. + * + * Return: 0 on success, -errno otherwise. */ -static int read_cr(struct spi_nor *nor) +static int spi_nor_read_cr(struct spi_nor *nor, u8 *cr) { int ret; @@ -462,20 +466,17 @@ static int read_cr(struct spi_nor *nor) SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDCR, 1), SPI_MEM_OP_NO_ADDR, SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1)); + SPI_MEM_OP_DATA_IN(1, cr, 1)); ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDCR, - nor->bouncebuf, 1); + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDCR, cr, 1); } - if (ret < 0) { + if (ret) dev_err(nor->dev, "error %d reading CR\n", ret); - return ret; - } - return nor->bouncebuf[0]; + return ret; } /* @@ -1768,7 +1769,8 @@ static int macronix_quad_enable(struct spi_nor *nor) * some very old and few memories don't support this instruction. If a pull-up * resistor is present on the MISO/IO1 line, we might still be able to pass the * "read back" test because the QSPI memory doesn't recognize the command, - * so leaves the MISO/IO1 line state unchanged, hence read_cr() returns 0xFF. + * so leaves the MISO/IO1 line state unchanged, hence spi_nor_read_cr(nor, cr) + * gets the 0xFF value. * * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI * memories. @@ -1787,8 +1789,11 @@ static int spansion_quad_enable(struct spi_nor *nor) return ret; /* read back and check it */ - ret = read_cr(nor); - if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) { + ret = spi_nor_read_cr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; + + if (!(nor->bouncebuf[0] & CR_QUAD_EN_SPAN)) { dev_err(nor->dev, "Spansion Quad bit not set\n"); return -EINVAL; } @@ -1839,21 +1844,18 @@ static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) */ static int spansion_read_cr_quad_enable(struct spi_nor *nor) { - struct device *dev = nor->dev; u8 *sr_cr = nor->bouncebuf; int ret; /* Check current Quad Enable bit value. */ - ret = read_cr(nor); - if (ret < 0) { - dev_err(dev, "error while reading configuration register\n"); - return -EINVAL; - } + ret = spi_nor_read_cr(nor, &sr_cr[1]); + if (ret) + return ret; - if (ret & CR_QUAD_EN_SPAN) + if (sr_cr[1] & CR_QUAD_EN_SPAN) return 0; - sr_cr[1] = ret | CR_QUAD_EN_SPAN; + sr_cr[1] |= CR_QUAD_EN_SPAN; /* Keep the current value of the Status Register. */ ret = spi_nor_read_sr(nor, &sr_cr[0]); @@ -1865,8 +1867,11 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) return ret; /* Read back and check it. */ - ret = read_cr(nor); - if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) { + ret = spi_nor_read_cr(nor, &sr_cr[1]); + if (ret) + return ret; + + if (!(sr_cr[1] & CR_QUAD_EN_SPAN)) { dev_err(nor->dev, "Spansion Quad bit not set\n"); return -EINVAL; } @@ -2007,20 +2012,15 @@ static int spi_nor_spansion_clear_sr_bp(struct spi_nor *nor) u8 *sr_cr = nor->bouncebuf; /* Check current Quad Enable bit value. */ - ret = read_cr(nor); - if (ret < 0) { - dev_err(nor->dev, - "error while reading configuration register\n"); + ret = spi_nor_read_cr(nor, &sr_cr[1]); + if (ret) return ret; - } /* * When the configuration register Quad Enable bit is one, only the * Write Status (01h) command with two data bytes may be used. */ - if (ret & CR_QUAD_EN_SPAN) { - sr_cr[1] = ret; - + if (sr_cr[1] & CR_QUAD_EN_SPAN) { ret = spi_nor_read_sr(nor, &sr_cr[0]); if (ret) return ret; From patchwork Tue Sep 17 15:55:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149063 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 610FB912 for ; Tue, 17 Sep 2019 16:02:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BBED214AF for ; Tue, 17 Sep 2019 16:02:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RnrGyrX1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="h4iGbpiw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BBED214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=pkybreQeeVN1YUaQDUJyDDKEHPeAmAODmiREQKoc/zg=; b=RnrGyrX1dwUBin p+hVom0y3NBlLRFJamfgznZZ4xwCXRVAKIJXUUiO5YNd1uTUxE970amu8Tur8YcXjLPjfEEpn7vwF XXlk82gmVBzDMtT5zp9yXkEYCq+TXJQIr9tzd9gnOBAgeVxVmorx2U6Z8gCKVkCTQHAsjOYM2RZ6h hULOBpsJzJ//Kz0sMJom3oBrDZEIZ0VLwyePZWiDVO+WjGvBZC5yzIP1CicQEtqC/ssgcXuYuQQdn znd3F5pKvFYkwrsoOF+zZOfWtxwYFOWmXz9UQoxKzZzNyJV3HB2Dex5EGPu+r1l8xuQLxMw/3XRNz kowAs5McpUv0jZ58OKfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFvU-0005a7-Kf; Tue, 17 Sep 2019 16:02:00 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFp4-0007sv-CM; Tue, 17 Sep 2019 15:55:24 +0000 Received-SPF: Pass (esa1.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa1.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa1.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: AZkRyVtZxYgI/U397LPNcDFw10NVPyuhK3cNau0DqB9jmCMjTB38n+fBGFjGB4PQvHmtMzuUzI hY/cQAMcGNh3RQjXhMzygPpUCCDlGvClxNPHNclwdYQ0mY/jFwinyRL1rjnNoYwOGQwnEFEW+F zvz4wUweXi5qQVQw5P7rv2hwJWrwyy9rCMroKPQ/XM+P+aip4LF5rEkOoJBA/uyeimOk6dJIqN HPkYeUkZMLXyyQSDqjG+48+LnxtIO7ly9C5T/fRJsr4eubju5txTMnh5ZlkKDY20FCwnqbFY7n aCs= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="50797834" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:21 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:09 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M/R1Y3BDShQ6gMv2218AY1L0o9ZBaVLkn05q6thR6RlRTYoa97EGellHbTCM2AR4rj8aCFifL8n4693eIs7QYMrIdVJUuvlFil77h2xuTAIn7WWWCp9pvYSNFajDtjKvF/fW9H/KAlYiYmJZYqNoq8X0C7XQBKmFeq0lHfjtwYCRBFS5fV0Fq0zl2TXy3gXUaO1q6ryqatR6NgKlstqsA302aeUF4qLWp0IiOFfTPdR6CMq/RE8G262NVfmPed5Q69+4hnm63HBcRrsl1vvauH1TPRI+53lief9E+BVOEUeHgVbbW8kNC3zAIk3o8OPSMsWExFSMDi1HEPT/wewxyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IgZDciRiYIn5RKBzZFdhKdyzvTYikOVy9DDuzMJiRUI=; b=VjboE633Sc/cNAh888RF6hWSVQlqt2QivaRiFjyR23LD499pWxZ4SK165YDf31cGauwjazwQ0h9Y+N93MwhHBf8/mVlfI7uErVzRrWS5knW21BVcZQMMInQHYgvtk28MI23Y6gu3AxKWNNOnIHPWa3hrK8SwPvShF0qbEdBs0a6RJVqjnrpCPgXDNzvg71VrLwah0yQ8PFdDeD8p3dlnY1UqDirJlWZfr5m/6Q9s0QVDFgUqOPU7dHI4l1DQIy31NzXK4Rfi7Pk9q/6TAG/U+CZN4f0NK8sna+Pw8dzKU3otEv6ABOeL6Pz+HTjnwIM/AiJ9wRZixlTSDMFUqswoCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IgZDciRiYIn5RKBzZFdhKdyzvTYikOVy9DDuzMJiRUI=; b=h4iGbpiw3dq7AmnlzboNaorNdcOEi2DJX2uWDTzGwVXhjvp3/GmehMyCfs4rHNjgDFO7rATlsyYPC4iinF45GiiH+tglSdyD96w15C7W/ZnAXnnH6mN+kl/nV/EE63oxTNE5uE2wJHqCL383CvCeInM19/t8nRwNSWi6djMRf3o= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:06 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:06 +0000 From: To: , , , , , Subject: [PATCH 08/23] mtd: spi-nor: Rework write_enable/disable() Thread-Topic: [PATCH 08/23] mtd: spi-nor: Rework write_enable/disable() Thread-Index: AQHVbXBGKtMISplgxk+FS63MDGaKQQ== Date: Tue, 17 Sep 2019 15:55:06 +0000 Message-ID: <20190917155426.7432-9-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c24be63-87dc-4abb-fae7-08d73b8768db x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: zDxtMPfQ41Dteye7JKq7mg6OpEbN6vwNDjBtLFwUJk6t9Qbu0wHmB6m9KOfi9UPuCIyrifX+mm1eHXIGPbrnxbXWTLArDXlI2/eDoj4WVcZ08Bxnrx/gMdNZUcsq/7JCvpTfDlW/lpTDbM10aw3KAfgKacrSkHn5xi8KPyZCubnyWxrReYs9SEI9OUIJZzvu5cgMGsB8hVGk0D7Yk6RETrCbMAz7gzra5a3ViLxbUW/ihvudtH6dihk/hj13HUvl0SyAsU4mkWLGYjynKWiuQ30QeJGLTEFuh9MFRAj/1eVvnKlcQOjywnF83MfU1EFoc4Ucckrzg2FR2fo9tHujGkIfA7RofvuCDOwQAUWiD5u1FZBXG5D8TxXANOIQP77B1SMgzuzq/EE48cU2kyFTF6lg5FBdDCHnx8kGWcnatd0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7c24be63-87dc-4abb-fae7-08d73b8768db X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:06.5383 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GVzgUKM+UXj5rpXkKt3BZmq4iXyN1dxsQZIaJwiu5Ka8tDIKtvttmS8XERuGkicy2g+Ipj6lJ7stiQn44hf781cnUFjpT/JijSOjT/X+NHc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085523_057763_D2D51268 X-CRM114-Status: GOOD ( 12.25 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.147.91 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus static int write_enable(struct spi_nor *nor) static int write_disable(struct spi_nor *nor) become static int spi_nor_write_enable(struct spi_nor *nor) static int spi_nor_write_disable(struct spi_nor *nor) Check for errors after each call to them. Move them up in the file as the first SPI NOR Register Operations, to avoid further forward declarations. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 175 +++++++++++++++++++++++++++++------------- 1 file changed, 120 insertions(+), 55 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 04491885b9bb..271c2b465038 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -389,6 +389,64 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, } /** + * spi_nor_write_enable() - Set write enable latch with Write Enable command. + * @nor: pointer to 'struct spi_nor' + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_enable(struct spi_nor *nor) +{ + int ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREN, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_NO_DATA); + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WREN, + NULL, 0); + } + + if (ret) + dev_err(nor->dev, "error %d on Write Enable\n", ret); + + return ret; +} + +/** + * spi_nor_write_disable() - Send Write Disable instruction to the chip. + * @nor: pointer to 'struct spi_nor' + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_disable(struct spi_nor *nor) +{ + int ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRDI, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_NO_DATA); + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WRDI, + NULL, 0); + } + + if (ret) + dev_err(nor->dev, "error %d on Write Disable\n", ret); + + return ret; +} + +/** * spi_nor_read_sr() - Read the Status Register. * @nor: pointer to 'struct spi_nor' * @sr: buffer where the value of the Status Register will be written. @@ -500,43 +558,6 @@ static int write_sr(struct spi_nor *nor, u8 val) nor->bouncebuf, 1); } -/* - * Set write enable latch with Write Enable command. - * Returns negative if error occurred. - */ -static int write_enable(struct spi_nor *nor) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREN, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_NO_DATA); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->write_reg(nor, SPINOR_OP_WREN, NULL, 0); -} - -/* - * Send write disable instruction to the chip. - */ -static int write_disable(struct spi_nor *nor) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRDI, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_NO_DATA); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->write_reg(nor, SPINOR_OP_WRDI, NULL, 0); -} - static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) { return mtd->priv; @@ -645,9 +666,15 @@ static int st_micron_set_4byte(struct spi_nor *nor, bool enable) { int ret; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + ret = macronix_set_4byte(nor, enable); - write_disable(nor); + if (ret) + return ret; + + ret = spi_nor_write_disable(nor); return ret; } @@ -701,9 +728,15 @@ static int winbond_set_4byte(struct spi_nor *nor, bool enable) * Register to be set to 1, so all 3-byte-address reads come from the * second 16M. We must clear the register to enable normal behavior. */ - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + ret = spi_nor_write_ear(nor, 0); - write_disable(nor); + if (ret) + return ret; + + ret = spi_nor_write_disable(nor); return ret; } @@ -1219,7 +1252,9 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len) list_for_each_entry_safe(cmd, next, &erase_list, list) { nor->erase_opcode = cmd->opcode; while (cmd->count) { - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + goto destroy_erase_cmd_list; ret = spi_nor_erase_sector(nor, addr); if (ret) @@ -1274,7 +1309,9 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) if (len == mtd->size && !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { unsigned long timeout; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + goto erase_err; if (erase_chip(nor)) { ret = -EIO; @@ -1302,7 +1339,9 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) /* "sector"-at-a-time erase */ } else if (spi_nor_has_uniform_erase(nor)) { while (len) { - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + goto erase_err; ret = spi_nor_erase_sector(nor, addr); if (ret) @@ -1323,7 +1362,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) goto erase_err; } - write_disable(nor); + ret = spi_nor_write_disable(nor); erase_err: spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_ERASE); @@ -1336,7 +1375,10 @@ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) { int ret; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + ret = write_sr(nor, status_new); if (ret) return ret; @@ -1681,7 +1723,9 @@ static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) { int ret; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; if (nor->spimem) { struct spi_mem_op op = @@ -1733,7 +1777,9 @@ static int macronix_quad_enable(struct spi_nor *nor) if (nor->bouncebuf[0] & SR_QUAD_EN_MX) return 0; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; write_sr(nor, nor->bouncebuf[0] | SR_QUAD_EN_MX); @@ -1936,7 +1982,9 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) /* Update the Quad Enable bit. */ *sr2 |= SR2_QUAD_EN_BIT7; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; ret = spi_nor_write_sr2(nor, sr2); if (ret < 0) { @@ -1978,7 +2026,9 @@ static int spi_nor_clear_sr_bp(struct spi_nor *nor) if (ret) return ret; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + return ret; ret = write_sr(nor, nor->bouncebuf[0] & ~mask); if (ret) { @@ -2601,7 +2651,9 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) return ret; - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + goto unlock_and_unprep; nor->sst_write_second = false; @@ -2640,14 +2692,19 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, } nor->sst_write_second = false; - write_disable(nor); + ret = spi_nor_write_disable(nor); + if (ret) + goto sst_write_err; + ret = spi_nor_wait_till_ready(nor); if (ret) goto sst_write_err; /* Write out trailing byte if it exists. */ if (actual != len) { - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + goto sst_write_err; nor->program_opcode = SPINOR_OP_BP; ret = spi_nor_write_data(nor, to, 1, buf + actual); @@ -2658,11 +2715,16 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ret = spi_nor_wait_till_ready(nor); if (ret) goto sst_write_err; - write_disable(nor); + + ret = spi_nor_write_disable(nor); + if (ret) + goto sst_write_err; + actual += 1; } sst_write_err: *retlen += actual; +unlock_and_unprep: spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE); return ret; } @@ -2710,7 +2772,10 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, addr = spi_nor_convert_addr(nor, addr); - write_enable(nor); + ret = spi_nor_write_enable(nor); + if (ret) + goto write_err; + ret = spi_nor_write_data(nor, addr, page_remain, buf + i); if (ret < 0) goto write_err; From patchwork Tue Sep 17 15:55:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82F8A16B1 for ; Tue, 17 Sep 2019 16:02:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E252214AF for ; Tue, 17 Sep 2019 16:02:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k1Pi0Lfs"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="kCrRmMP6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E252214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=MNxmCeDkGXNbN21eCWA/b7wcoK3QNC1MaOW37Rq+3/I=; b=k1Pi0Lfs6MRFmu b7ReH2v98Cr22JVEDw0brnq9zGAKkTQRWI5VyzNK/Xg6y6eiJB1wCaAQgFSXzhz20tIA8uKsxb1Nv J78va0FdYgn1n/KGm0RwSYsl/PNMlm/b1VxtkKA6CsIWW0Xi/tnBN1a3eR0AXbQB6HGJcM2pYL8s+ 69Wxbv3xVn54J+nYy9657jY7k8/ete15Am13M7w3c6ceHga7pb5ztHisi2CQND6M+D9BrQI46zMcl aYdPk4DmxGoklQCjhE3tN0fdL1ejp5lTkJqYrGYcbP8TJ+piHS0iUbNbutFake/YHdoubi8KyspeP naCtgsUwU9/ulhdD+Zpw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFw0-0006Ac-Kp; Tue, 17 Sep 2019 16:02:32 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFp8-0007vb-Hw; Tue, 17 Sep 2019 15:55:28 +0000 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: RmRHi3caIAIgEO/lUR05uA+BO9RMSlGeO9K6WpnOCPEIU8Zl//np9bgsG6wyWNNU/8zxRiicbq WWh2ch0ShKXDJe/3zQv1GoZybtHgCO5nADSEErYnfb62M4wEkuJgaCNDR3uqgFRS54nsH6Bx+n o5GR8fBmbcnVrayAUrgIkPyDPNtLQf+5nPzCGpJJBxcjgnNe1Kuk37CUJnMZsBGKp2hibI3wka eodtoaJfdjbTfrNXnniAc7hWfvuOP0umm++moKVt+3QxqqNmS5CHw+bdKuxyS44qHiAGCog2ZR Lig= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="46517742" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:25 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:15 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ex8NE5Eh+t9Q2bcHfXX+cYAC26aQVisrVlD5hKUF+OjgFHKCND9Xk6sIOcCTxHHtk46paj/Hg1zlxb0/ZS6sDL3swpk7hS5vQF7qKGzVT4KNG3GXn8ftNNs8TVeRMs6+HF8WmnmgBCqDVz9NY6nG83EIYjedgIuAs/rtA0FTFhuqEDu3rm1OrlIDDDG1+u6b6lDGQSFIdfQR2NPuh83wohf1yXXSLMin1FhE1VNxmb0Bv/DCscLaPzAVqVNWTVgPpxmUVtOYkzXiiUDXO3AK4+fuLSkY6mrz/6uqYuhx62etKcqYzQ5m36MxvA+yffX8rWwjl1lRc0/H1aJrGtMctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FfNIlmP+zexOyiZQZZDTj5QUb3ATwRtXvE2VJWmSigo=; b=DgG8qJIbjhrYQK3M/uimH8QOwJSzAVyRmLy/9JfyCN10+wY3uXSYgnmjUzbiwZ1w7e+fzCXwjypDUtBdnnHyqgOVsCIlCUllVyR5P6nBDH50ryWAvynmYvsesc8Qv/R9pLFXK+Fpm/gM3ROa2vDz76HEZm5fdubyTgDlVT7Qoh6dr+azuh0pzXQ3w6a9lYJfhDja3QIacToUyq2bxwY75t6iGJz/p9BcOwa6il5oPWRhcRW67w84qZtLlfsFgD3u+u4W42iVG5Zu1XiHG54zCfEPnIQYrbfTPSIceM0QGuH9Rc2vVZXZDUUVab0ErXiDZTAKA1UcjbyFkoMloGnU0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FfNIlmP+zexOyiZQZZDTj5QUb3ATwRtXvE2VJWmSigo=; b=kCrRmMP641rzEtME99X3CmD82iptAuQ61uSmBhtwOHuaSsgRho8CXYTvoh9lQ/wYmXiYq9slHsYnJLlYf6kHQHf3f6RLvQjxGOFW/cGaXUHoXESWbbFn7Ytt32azkCasXfk7WdNdaaprBNQUNmQhQKtz0PgBMCbL0HpjhBwfBe8= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:09 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:09 +0000 From: To: , , , , , Subject: [PATCH 09/23] mtd: spi-nor: Fix retlen handling in sst_write() Thread-Topic: [PATCH 09/23] mtd: spi-nor: Fix retlen handling in sst_write() Thread-Index: AQHVbXBIyC+efO45bES0NItE97wYMw== Date: Tue, 17 Sep 2019 15:55:09 +0000 Message-ID: <20190917155426.7432-10-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7be4ab58-10c8-4d45-5dc4-08d73b876ac3 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 5xaQsUJmwxm42EZQf0PXNo6tpN1yZ/9fRTniQe9KxM5VdKgM3t9kRoM2L8fz02OyMCvu8xr8Sje50q2PxybLn0XmoiCgc8eLVyu1i5lYneSS3x6dn9SdlEvNg8YkostX1QHrBU0WgJd0IPAL9l01tnRdBbNcai4OTGChOKiQSNY5n6tftV4VNlPaHCBHKQWSNGNi6mIF6sY1oVLxhqisMcVZFh7VjN3j3qfhVQZ0VhUZefgT56Sk4DlJMEal4YIX3zN471AZtjRKvelPAqL7TtdC9XYxvLKo6cdBlpatrR+SCBvbYMEfn5mChlQ5Mpfh8q0I3zWTp56t6f8+GU8TOcrzyrcEOTKSA+S8AiNHXM4DQPPcZHrdRMNNAA5jxob5kkEZcQlDAxZFeBqeSiVfucc9LMFfAddypaWIag4g+ec= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7be4ab58-10c8-4d45-5dc4-08d73b876ac3 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:09.7384 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yX7DwB9J79gXoI9mUBG3lhplNs4h036VlzpanIkvcJ+HuMm7S0hwW+8npjbfDrrZ8uHCn7K/sOua5asVlRmVLw7pkPNw7/95KcG+ukKBjNk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085527_022134_11618925 X-CRM114-Status: GOOD ( 10.23 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus In case the write of the first byte failed, retlen was incorrectly incremented to *retlen += actual; on the exit path. retlen should be incremented when actual data was written to the flash. Rename 'sst_write_err' label to 'out' as it is no longer generic for all the write errors in the sst_write() method, and may introduce confusion. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 271c2b465038..151db98f7d49 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2665,12 +2665,12 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, /* write one byte. */ ret = spi_nor_write_data(nor, to, 1, buf); if (ret < 0) - goto sst_write_err; + goto unlock_and_unprep; WARN(ret != 1, "While writing 1 byte written %i bytes\n", (int)ret); ret = spi_nor_wait_till_ready(nor); if (ret) - goto sst_write_err; + goto unlock_and_unprep; } to += actual; @@ -2681,12 +2681,12 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, /* write two bytes. */ ret = spi_nor_write_data(nor, to, 2, buf + actual); if (ret < 0) - goto sst_write_err; + goto out; WARN(ret != 2, "While writing 2 bytes written %i bytes\n", (int)ret); ret = spi_nor_wait_till_ready(nor); if (ret) - goto sst_write_err; + goto out; to += 2; nor->sst_write_second = true; } @@ -2694,35 +2694,35 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ret = spi_nor_write_disable(nor); if (ret) - goto sst_write_err; + goto out; ret = spi_nor_wait_till_ready(nor); if (ret) - goto sst_write_err; + goto out; /* Write out trailing byte if it exists. */ if (actual != len) { ret = spi_nor_write_enable(nor); if (ret) - goto sst_write_err; + goto out; nor->program_opcode = SPINOR_OP_BP; ret = spi_nor_write_data(nor, to, 1, buf + actual); if (ret < 0) - goto sst_write_err; + goto out; WARN(ret != 1, "While writing 1 byte written %i bytes\n", (int)ret); ret = spi_nor_wait_till_ready(nor); if (ret) - goto sst_write_err; + goto out; ret = spi_nor_write_disable(nor); if (ret) - goto sst_write_err; + goto out; actual += 1; } -sst_write_err: +out: *retlen += actual; unlock_and_unprep: spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE); From patchwork Tue Sep 17 15:55:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C94716B1 for ; Tue, 17 Sep 2019 16:03:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 069C6214AF for ; Tue, 17 Sep 2019 16:03:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ETikw/mO"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="MnTZOzbh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 069C6214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=0UyFaAphJoP/EtbbpAK2K2M1lnVzIf2NhKXaB1mGlMg=; b=ETikw/mOJdaNiF nx0+W+K/BdYS834EDVP5Tsj5wUKO8O3RtyEz4lRKES/IVYWLWY0X1aT9AKx0fI21kn9mpU7oRCZVY zjFXJ9xKkZbvUG/RyvyvkP2js8cWJ/BXo0OhvBKdI/phuCnnezDkz/U48EnrwLoyijQXxVssIQ2yZ yy8vkzblmBNiNcQQCv7I4WzSTWhxwuKm4Sf1x3b4BOXy83L7n0zy5c7VH8PmM+qprHYcJMxUFwwIr 9PYkD+8Clvd6seEFKCSQVVV/nVdByoBmqRRGxXIYRwXPHLkXiluWHcjk62LciY9MTeqpRm5luE9D7 /T2MJL6+xyl7Ysgt/xIw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFwZ-0006lM-BX; Tue, 17 Sep 2019 16:03:07 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpA-0007sv-Sx; Tue, 17 Sep 2019 15:55:31 +0000 Received-SPF: Pass (esa1.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa1.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa1.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: WhD/gKXdmtKOsC5G1jtxVPmuCExP/KJdRxnoggEdQihOiueL2RBFGuJftNyNca0Moe73SKYMwa NfUP1NlwAVqbz+X77mkOgUSwY1hWSNbkNQ01U1VpwOWvwaqK7E0NDaBPTR8lsFTQPpKwMyOcWU xZpHmmy6sIIWxyqt05DNeVAEkQolvfLGy2rLFYT1sAtfeAStXJlTMcw3xsR3ZYZglJeFQ3xa4Q OEvHYGvjUCYqM9Gg7yLeffYDuNasAw3Dl2V8sfhmdTnOHo/gsn3tySdNa4pbIeMMte9e82xNhN Zvw= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="50797882" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:27 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:16 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nrry2eM9cAI0/lyTfXR6WgJTWnmEglz0Ts+k+TSmdUm8pM1r8nCQ5kUkJ8RDj6HrtsNXfy+x3NV35D1JZRnqWhMCtpjHFQT/7r1vpres/f4OxJDT5RlqOuYoCi39ZRCxkNGEeZKPCc9Fx72JkSo+ThZvtAJkAqyS+CRhj1eC2jAO/HeIzIn3JVLHZ9wdWt+yiEGEXPJx7lWQbjboNpzazeOKE3xC+xTU/bOYu8aV9mvomKRh+skh17xgArhDAVLr7LgZnYTooFI92qJhVjUKEXPt3fae0rGEBqggA8TVYxzqJoldBmakf8rTn/ZPOQxzCF93VVYW8ApwOA5pcOmxQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wkd0mb/TC7YEpC7rS/UP8xltuN5LoRChsbp6da+fX3k=; b=nuMADUFv6TqtQTxXRiVr4kh2IORmoljtDHC7QYUfiQI33+vvkOHeAdSZAHhlNnlaRVzxkrhxxRI6sN/oEVv+ov56VV0biZmpy1wz5tsDHw34GI16pcffEJubs+grTvhoCTh5MCXz6ve/Dxw/NLEIv8Pbd1hwqv9WNGoi7BTbbrjczmhS4COSY2AnqxUl7MLDAhzKiIRHe44bFyrFj6COMYeGhB7iUYVJzchEBB0LNTn3W+UT2r3XjQcs+m8a43ssBcfOhQZYUqegOgDybnuDDVak+RLnjWApO+n+OYKijdN/c6akeEnhaiZ8UDIqRvg/zXF9Nnx1kNlIPzDtNbT0eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wkd0mb/TC7YEpC7rS/UP8xltuN5LoRChsbp6da+fX3k=; b=MnTZOzbhVqOr14ED8qs2o2Kh+sVhRiuEVHRghIHJ/C2XAHsxql+wHYZAoB7xkA9ajGcInjYCs9JrhPr5xTZCgZCpwXuLfbp+spaXK9iX+EKCrlGGiQd9vXR7ZnnzhDjxGdyE+6pFZXtOZUf3eXG2qEu8RHJm85wyuTQ8/X7064c= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:13 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:13 +0000 From: To: , , , , , Subject: [PATCH 10/23] mtd: spi-nor: Rework write_sr() Thread-Topic: [PATCH 10/23] mtd: spi-nor: Rework write_sr() Thread-Index: AQHVbXBKtPPmx1X0Qk6m6KvCcAvgdg== Date: Tue, 17 Sep 2019 15:55:12 +0000 Message-ID: <20190917155426.7432-11-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 361aabc7-6174-4944-9d73-08d73b876cb1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(14444005)(30864003)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: K7Tsuy8nW3rVOyW7/DaK8RrrHLr9Y2Uf6XylJOHh36rUH+yEbyFkcXrNrJD7IR07la83l2jzXjpBWNLW0uuHtoSneZup0pQKzqVnSJ90QAfaf/HFaO1YNimE8e+1B67jmDWYFCDZXxEoeVnv0jMe/muCyJhkol6AwZkoWNESoUpCHlNl1dR8kGZOodJwdl6lYVMEa/9lOZNoSCPKU08deGOsxfdDuDaOvf38/dXxlWmw/RzHQVmROCSML0i9xZ2y3C9FpF+MjOAt/vSd3RyHRSTCN+2Q/RfPNxORxzxZAfuwiatDIVL6p/jVBkjAgHZtccN3fwnN/WSrH4UhdVSH397XJn1Eik0uarO4wPBKOzDuny/kTC/nAD3KadsvHIMMkdnTcQ0r88XiE1ayMG+bNcMmKQmdthRXqzLCCblPyQY= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 361aabc7-6174-4944-9d73-08d73b876cb1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:12.9306 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mAkdvZvFIpFU/wXv8kpexnagjLl/DLodK0Rk93cMQ3XKRvu82jAD0092e+BLgzgfDBkeb3NcN5jDYnt2Znx+qpe5bQgDTqldHAkQbCfLmWw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085529_263397_EE7DE5E3 X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.147.91 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus The Status Register can be written with one or two bytes. Merge: static int write_sr(struct spi_nor *nor, u8 val) static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) into static int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len) Avoid duplicating code by moving the calls to spi_nor_write_enable() and spi_nor_wait_till_ready() inside spi_nor_write_sr(). Move the spi_nor_wait_till_ready() together with the spi_nor_ready() methods to avoid forward declarations. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 426 +++++++++++++++++++----------------------- 1 file changed, 191 insertions(+), 235 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 151db98f7d49..89800bbaa179 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -537,25 +537,198 @@ static int spi_nor_read_cr(struct spi_nor *nor, u8 *cr) return ret; } +static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) +{ + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_XRDSR, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_DATA_IN(1, sr, 1)); + + return spi_mem_exec_op(nor->spimem, &op); + } + + return nor->controller_ops->read_reg(nor, SPINOR_OP_XRDSR, sr, 1); +} + +static int s3an_sr_ready(struct spi_nor *nor) +{ + int ret; + + ret = spi_nor_xread_sr(nor, nor->bouncebuf); + if (ret < 0) { + dev_err(nor->dev, "error %d reading XRDSR\n", (int) ret); + return ret; + } + + return !!(nor->bouncebuf[0] & XSR_RDY); +} + +static int spi_nor_clear_sr(struct spi_nor *nor) +{ + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLSR, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_NO_DATA); + + return spi_mem_exec_op(nor->spimem, &op); + } + + return nor->controller_ops->write_reg(nor, SPINOR_OP_CLSR, NULL, 0); +} + +static int spi_nor_sr_ready(struct spi_nor *nor) +{ + int ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + + if (ret) + return ret; + + if (nor->flags & SNOR_F_USE_CLSR && + nor->bouncebuf[0] & (SR_E_ERR | SR_P_ERR)) { + if (nor->bouncebuf[0] & SR_E_ERR) + dev_err(nor->dev, "Erase Error occurred\n"); + else + dev_err(nor->dev, "Programming Error occurred\n"); + + spi_nor_clear_sr(nor); + return -EIO; + } + + return !(nor->bouncebuf[0] & SR_WIP); +} + +static int spi_nor_clear_fsr(struct spi_nor *nor) +{ + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLFSR, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_NO_DATA); + + return spi_mem_exec_op(nor->spimem, &op); + } + + return nor->controller_ops->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0); +} + +static int spi_nor_fsr_ready(struct spi_nor *nor) +{ + int ret = spi_nor_read_fsr(nor, &nor->bouncebuf[0]); + + if (ret) + return ret; + + if (nor->bouncebuf[0] & (FSR_E_ERR | FSR_P_ERR)) { + if (nor->bouncebuf[0] & FSR_E_ERR) + dev_err(nor->dev, "Erase operation failed.\n"); + else + dev_err(nor->dev, "Program operation failed.\n"); + + if (nor->bouncebuf[0] & FSR_PT_ERR) + dev_err(nor->dev, + "Attempted to modify a protected sector.\n"); + + spi_nor_clear_fsr(nor); + return -EIO; + } + + return nor->bouncebuf[0] & FSR_READY; +} + +static int spi_nor_ready(struct spi_nor *nor) +{ + int sr, fsr; + + if (nor->flags & SNOR_F_READY_XSR_RDY) + sr = s3an_sr_ready(nor); + else + sr = spi_nor_sr_ready(nor); + if (sr < 0) + return sr; + fsr = nor->flags & SNOR_F_USE_FSR ? spi_nor_fsr_ready(nor) : 1; + if (fsr < 0) + return fsr; + return sr && fsr; +} + /* - * Write status register 1 byte - * Returns negative if error occurred. + * Service routine to read status register until ready, or timeout occurs. + * Returns non-zero if error. + */ +static int spi_nor_wait_till_ready_with_timeout(struct spi_nor *nor, + unsigned long timeout_jiffies) +{ + unsigned long deadline; + int timeout = 0, ret; + + deadline = jiffies + timeout_jiffies; + + while (!timeout) { + if (time_after_eq(jiffies, deadline)) + timeout = 1; + + ret = spi_nor_ready(nor); + if (ret < 0) + return ret; + if (ret) + return 0; + + cond_resched(); + } + + dev_err(nor->dev, "flash operation timed out\n"); + + return -ETIMEDOUT; +} + +static int spi_nor_wait_till_ready(struct spi_nor *nor) +{ + return spi_nor_wait_till_ready_with_timeout(nor, + DEFAULT_READY_WAIT_JIFFIES); +} + +/** + * spi_nor_write_sr() - Write the Status Register. + * @nor: pointer to 'struct spi_nor'. + * @sr: buffer to write to the Status Register. + * len: number of bytes to write to the Status Register. + * + * Return: 0 on success, -errno otherwise. */ -static int write_sr(struct spi_nor *nor, u8 val) +static int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len) { - nor->bouncebuf[0] = val; + int ret; + + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + if (nor->spimem) { struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR, 1), SPI_MEM_OP_NO_ADDR, SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1)); + SPI_MEM_OP_DATA_OUT(len, sr, 1)); - return spi_mem_exec_op(nor->spimem, &op); + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR, + sr, len); } - return nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR, - nor->bouncebuf, 1); + if (ret) { + dev_err(nor->dev, "error while writing Status Register\n"); + return ret; + } + + ret = spi_nor_wait_till_ready(nor); + + return ret; } static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) @@ -741,161 +914,6 @@ static int winbond_set_4byte(struct spi_nor *nor, bool enable) return ret; } -static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_XRDSR, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_IN(1, sr, 1)); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->read_reg(nor, SPINOR_OP_XRDSR, sr, 1); -} - -static int s3an_sr_ready(struct spi_nor *nor) -{ - int ret; - - ret = spi_nor_xread_sr(nor, nor->bouncebuf); - if (ret < 0) { - dev_err(nor->dev, "error %d reading XRDSR\n", (int) ret); - return ret; - } - - return !!(nor->bouncebuf[0] & XSR_RDY); -} - -static int spi_nor_clear_sr(struct spi_nor *nor) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLSR, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_NO_DATA); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->write_reg(nor, SPINOR_OP_CLSR, NULL, 0); -} - -static int spi_nor_sr_ready(struct spi_nor *nor) -{ - int ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); - - if (ret) - return ret; - - if (nor->flags & SNOR_F_USE_CLSR && - nor->bouncebuf[0] & (SR_E_ERR | SR_P_ERR)) { - if (nor->bouncebuf[0] & SR_E_ERR) - dev_err(nor->dev, "Erase Error occurred\n"); - else - dev_err(nor->dev, "Programming Error occurred\n"); - - spi_nor_clear_sr(nor); - return -EIO; - } - - return !(nor->bouncebuf[0] & SR_WIP); -} - -static int spi_nor_clear_fsr(struct spi_nor *nor) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLFSR, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_NO_DATA); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0); -} - -static int spi_nor_fsr_ready(struct spi_nor *nor) -{ - int ret = spi_nor_read_fsr(nor, &nor->bouncebuf[0]); - - if (ret) - return ret; - - if (nor->bouncebuf[0] & (FSR_E_ERR | FSR_P_ERR)) { - if (nor->bouncebuf[0] & FSR_E_ERR) - dev_err(nor->dev, "Erase operation failed.\n"); - else - dev_err(nor->dev, "Program operation failed.\n"); - - if (nor->bouncebuf[0] & FSR_PT_ERR) - dev_err(nor->dev, - "Attempted to modify a protected sector.\n"); - - spi_nor_clear_fsr(nor); - return -EIO; - } - - return nor->bouncebuf[0] & FSR_READY; -} - -static int spi_nor_ready(struct spi_nor *nor) -{ - int sr, fsr; - - if (nor->flags & SNOR_F_READY_XSR_RDY) - sr = s3an_sr_ready(nor); - else - sr = spi_nor_sr_ready(nor); - if (sr < 0) - return sr; - fsr = nor->flags & SNOR_F_USE_FSR ? spi_nor_fsr_ready(nor) : 1; - if (fsr < 0) - return fsr; - return sr && fsr; -} - -/* - * Service routine to read status register until ready, or timeout occurs. - * Returns non-zero if error. - */ -static int spi_nor_wait_till_ready_with_timeout(struct spi_nor *nor, - unsigned long timeout_jiffies) -{ - unsigned long deadline; - int timeout = 0, ret; - - deadline = jiffies + timeout_jiffies; - - while (!timeout) { - if (time_after_eq(jiffies, deadline)) - timeout = 1; - - ret = spi_nor_ready(nor); - if (ret < 0) - return ret; - if (ret) - return 0; - - cond_resched(); - } - - dev_err(nor->dev, "flash operation timed out\n"); - - return -ETIMEDOUT; -} - -static int spi_nor_wait_till_ready(struct spi_nor *nor) -{ - return spi_nor_wait_till_ready_with_timeout(nor, - DEFAULT_READY_WAIT_JIFFIES); -} - /* * Erase the whole flash memory * @@ -1375,15 +1393,9 @@ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) { int ret; - ret = spi_nor_write_enable(nor); - if (ret) - return ret; - - ret = write_sr(nor, status_new); - if (ret) - return ret; + nor->bouncebuf[0] = status_new; - ret = spi_nor_wait_till_ready(nor); + ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); if (ret) return ret; @@ -1713,49 +1725,6 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) return ret; } -/* - * Write status Register and configuration register with 2 bytes - * The first byte will be written to the status register, while the - * second byte will be written to the configuration register. - * Return negative if error occurred. - */ -static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) -{ - int ret; - - ret = spi_nor_write_enable(nor); - if (ret) - return ret; - - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_OUT(2, sr_cr, 1)); - - ret = spi_mem_exec_op(nor->spimem, &op); - } else { - ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR, - sr_cr, 2); - } - - if (ret < 0) { - dev_err(nor->dev, - "error while writing configuration register\n"); - return -EINVAL; - } - - ret = spi_nor_wait_till_ready(nor); - if (ret) { - dev_err(nor->dev, - "timeout while writing configuration register\n"); - return ret; - } - - return 0; -} - /** * macronix_quad_enable() - set QE bit in Status Register. * @nor: pointer to a 'struct spi_nor' @@ -1777,13 +1746,9 @@ static int macronix_quad_enable(struct spi_nor *nor) if (nor->bouncebuf[0] & SR_QUAD_EN_MX) return 0; - ret = spi_nor_write_enable(nor); - if (ret) - return ret; - - write_sr(nor, nor->bouncebuf[0] | SR_QUAD_EN_MX); + nor->bouncebuf[0] |= SR_QUAD_EN_MX; - ret = spi_nor_wait_till_ready(nor); + ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); if (ret) return ret; @@ -1830,7 +1795,7 @@ static int spansion_quad_enable(struct spi_nor *nor) sr_cr[0] = 0; sr_cr[1] = CR_QUAD_EN_SPAN; - ret = write_sr_cr(nor, sr_cr); + ret = spi_nor_write_sr(nor, sr_cr, 2); if (ret) return ret; @@ -1872,7 +1837,7 @@ static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) sr_cr[1] = CR_QUAD_EN_SPAN; - return write_sr_cr(nor, sr_cr); + return spi_nor_write_sr(nor, sr_cr, 2); } /** @@ -1908,7 +1873,7 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) if (ret) return ret; - ret = write_sr_cr(nor, sr_cr); + ret = spi_nor_write_sr(nor, sr_cr, 2); if (ret) return ret; @@ -2026,19 +1991,10 @@ static int spi_nor_clear_sr_bp(struct spi_nor *nor) if (ret) return ret; - ret = spi_nor_write_enable(nor); - if (ret) - return ret; + nor->bouncebuf[0] &= mask; - ret = write_sr(nor, nor->bouncebuf[0] & ~mask); - if (ret) { - dev_err(nor->dev, "write to status register failed\n"); - return ret; - } + ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); - ret = spi_nor_wait_till_ready(nor); - if (ret) - dev_err(nor->dev, "timeout while writing status register\n"); return ret; } @@ -2077,7 +2033,7 @@ static int spi_nor_spansion_clear_sr_bp(struct spi_nor *nor) sr_cr[0] &= ~mask; - ret = write_sr_cr(nor, sr_cr); + ret = spi_nor_write_sr(nor, sr_cr, 2); if (ret) dev_err(nor->dev, "16-bit write register failed\n"); return ret; From patchwork Tue Sep 17 15:55:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8838F16B1 for ; Tue, 17 Sep 2019 16:03:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62799214AF for ; Tue, 17 Sep 2019 16:03:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cJjA3zWJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="r2uP49bI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62799214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=ddg52TV1ZHOK3dbhXFiA8kkJnlRPApi0yuL+/f9+moo=; b=cJjA3zWJXCSOUe uKV/L938Alf4ZowTEACx48xZeMMOFHhqtyi72ltQBej6hYL7QA9YbQOoRYppv2/yqGtz6N24lAZtr FCILQW5wBpF5RGiTNZVu6FV5MJE5o7yhyzzohpuslFOKflGDLV9vsu3dv5MeVfuUjTUQ04UK5DxYS qbO8eFClk9FgmY2QX8MzlluVE65jHF4kCVRKUUZVH/nscGiuzcbemIBX1ph4exWSE+/iZlTesfWNJ gRH1c5Ji0u/9UyySiS3bmfopjrWk6cI0Jmlh/STpaNkBjnB6vbUXzEnL5nB7I1pLRpIedzG4r6day o8ki6rJfK3RmOMML0XSA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFx4-0007GD-Qt; Tue, 17 Sep 2019 16:03:38 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpD-0007xT-6w; Tue, 17 Sep 2019 15:55:32 +0000 Received-SPF: Pass (esa1.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa1.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa1.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: uMDpyttlFCL+8hYuDXQ6gI3yCcBkshfBfxDTHwZwCOVLXh5xTfGLW/HMsA6Sk9PSw5ZHSm02aN F4sm2Bf8Ga5FsHlQ/vOE8Z2Jt7H1nqDM582a3O5CS3zXHEfIlFveRxiIfV7X37SG2ykWG99lSX vayvma7RVMuhCJt/jNZtdRr2AGC0QtVc7HeLaYbRdEKc32bmyuJhVghCs8q7cK9u2QnF1OSlV/ noM+yHJWNyNnvpYI1LrMY/t21wjH0pjU1JeqcJ/s9VAMcjHx1eiP+x8UWuYtCJx3kHg6XRQspq m7o= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="50797897" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:30 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:27 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IWpXtRIPiveQyzUoV3zz9UcotWAJylQCpPJJOvHWiV1MFUOQaLRiRXHyIGZavcuqysxfEKEXJ5xunyZl6zMa7GFrmgNqMdHiFRWBWGPLxQxq+S8HXiiCpWXhiY4Xo0Bo4st1LFm8FO9o9GRx1VfT0zmSR571UZb6riXZsfv/NbI19HUEUxtUHZuUsxntK6Vb1UEjDltAUulhkPg7w17eVIeZviuuqtpKgRiLK+rI0WTmqgQBf8nkoXLlncRUvPeMRWoTg+KYxuDhinsHsuXfUXd0cusnZMJcvs1rq262OJlJILGo6Uao5p+/KobpoNwWJttVUOrwwNwUkhNLe1cEBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mC32JdAt86fa7oXSG6f0EqDhlEmzIFrJvA9LI5zuTPI=; b=CZnjaxPj2baF/FOrpKdjgDkY4+YJ+ZDTE/ZFNp3+bGH4rmKrIhu20bhJoTyq2wEHulFEz8fEoe3jB1UidkUJJi5JM8Cc6c1v04ZVRhOgwr87KP1B2g0kbk1YcSU5P7u0wkUaCM3BTOHsSAaKTO2MnP4+7qd75+Hb/ze9jlMLhh5KSFn1xUxjwGNXyj5ll9h0bnU00vB60LVf9HclnJ5Q1Zm1pxMbw6qdNt/rPZBPttCWQvRFI9eWBmEaienmC8F8meDRh03NMtrREnclMJWrkdqd3B+b7UVxS7eq94MpQd0EzZLtlBzWXHvIsmEgdtwtjV2eKTflkbhFDcOuAPaWIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mC32JdAt86fa7oXSG6f0EqDhlEmzIFrJvA9LI5zuTPI=; b=r2uP49bIePSxKFHO2kAj6MPO/8/hzxAhjtkkUpnUBVoz25KfU2spX3xbWoI69F3GjGQES1iD3QZVFL5XxVx7c/6uP7BxQPy7YKUVZelvwI4FDJoZ6Lo6SaIHhZLwLGvacVo3UjnLGPdIOn+hRZ7U9fkXGcpJOVseuERAT7ZCL/0= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:16 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:16 +0000 From: To: , , , , , Subject: [PATCH 11/23] mtd: spi-nor: Rework spi_nor_read/write_sr2() Thread-Topic: [PATCH 11/23] mtd: spi-nor: Rework spi_nor_read/write_sr2() Thread-Index: AQHVbXBMGRFdS0Dx4UqQ4KTJNdCVXA== Date: Tue, 17 Sep 2019 15:55:16 +0000 Message-ID: <20190917155426.7432-12-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 54e804e3-defb-468b-8759-08d73b876e91 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: uidy9oD4+KPaxmJIbXIxn4Yd5BekidyWNSsO7cczcs6YdOCr6Xv3SiN5NRvPHprQHr5L3VKfK/LZlIAuTuufptNkPdoYdWckb1CKyLKciozdnkXDt7MawKeVnTHCEWwWg94t3sz3ppHoDYXEB3zlcHPckDfjkIMUOHyLxLRc2keeTmchY75XvIDPtMk/IlX9bhDIqaWdTy+go7iM3oCJ/DOd3rgrpJ2NUOOlyFuoZKehv/fGRu9Q2twRZOuKIpMev089MBj+l0HzYrYohQZjqKI9EuAWZRWr7nKx61x5nwAyx56qQjUhF/0m/SOMrU49S736dSLUfpqJ0bK03GFo8gqRfoqCKtGNks7ysqWKNFMfDsMdPdcEu6aW46x/2AKWxSpxc7lm83X4XaSPetiDSxZJhdDqwVwkx4K10+4DncU= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 54e804e3-defb-468b-8759-08d73b876e91 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:16.0787 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BNGAP3C5tHlTsJG6LxXmPAtmkUXxgtp8G5P5cpE36eFAuavi1NrqZHvEhUCHEKUFJ+Eo/20I27x80PQy9YKNJLLvo0L9x8gPGLUiqOaYlbk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085531_507149_EC6878CA X-CRM114-Status: GOOD ( 12.34 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.147.91 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Move the methods up in the file, where the other Register operations reside. The error is reported inside each SR2 function, to spare the callers of duplicating code. Constify sr2 in spi_nor_write_sr2(). Do the spi_nor_write_enable() and spi_nor_wait_till_ready() inside spi_nor_write_sr2(), as the spi_nor_write_sr() does. While modyfing sr2_bit7_quad_enable(), add a new line for better code readability. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 118 ++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 44 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 89800bbaa179..c06de7ad6434 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -731,6 +731,74 @@ static int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len) return ret; } +/** + * spi_nor_write_sr2() - Write the Status Register 2 using the + * SPINOR_OP_WRSR2 (3eh) command. + * @nor: pointer to 'struct spi_nor'. + * @sr2: buffer to write to the Status Register. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_sr2(struct spi_nor *nor, const u8 *sr2) +{ + int ret; + + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR2, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_DATA_OUT(1, sr2, 1)); + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR2, + sr2, 1); + } + + if (ret) + dev_err(nor->dev, "error while writing Status Register 2\n"); + + ret = spi_nor_wait_till_ready(nor); + + return ret; +} + +/** + * spi_nor_read_sr2() - Read the Status Register 2 using the + * SPINOR_OP_RDSR2 (3fh) command. + * @nor: pointer to 'struct spi_nor' + * @sr2: buffer where the value of the Status Register will be written. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) +{ + int ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR2, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_DATA_IN(1, sr2, 1)); + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR2, + sr2, 1); + } + + if (ret) + dev_err(nor->dev, "error while reading Status Register 2\n"); + + return ret; +} + static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) { return mtd->priv; @@ -1890,36 +1958,6 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) return 0; } -static int spi_nor_write_sr2(struct spi_nor *nor, u8 *sr2) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR2, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_OUT(1, sr2, 1)); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->write_reg(nor, SPINOR_OP_WRSR2, sr2, 1); -} - -static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) -{ - if (nor->spimem) { - struct spi_mem_op op = - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR2, 1), - SPI_MEM_OP_NO_ADDR, - SPI_MEM_OP_NO_DUMMY, - SPI_MEM_OP_DATA_IN(1, sr2, 1)); - - return spi_mem_exec_op(nor->spimem, &op); - } - - return nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR2, sr2, 1); -} - /** * sr2_bit7_quad_enable() - set QE bit in Status Register 2. * @nor: pointer to a 'struct spi_nor' @@ -1941,31 +1979,23 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) ret = spi_nor_read_sr2(nor, sr2); if (ret) return ret; + if (*sr2 & SR2_QUAD_EN_BIT7) return 0; /* Update the Quad Enable bit. */ *sr2 |= SR2_QUAD_EN_BIT7; - ret = spi_nor_write_enable(nor); - if (ret) - return ret; - ret = spi_nor_write_sr2(nor, sr2); - if (ret < 0) { - dev_err(nor->dev, "error while writing status register 2\n"); - return -EINVAL; - } - - ret = spi_nor_wait_till_ready(nor); - if (ret < 0) { - dev_err(nor->dev, "timeout while writing status register 2\n"); + if (ret) return ret; - } /* Read back and check it. */ ret = spi_nor_read_sr2(nor, sr2); - if (!(ret > 0 && (*sr2 & SR2_QUAD_EN_BIT7))) { + if (ret) + return ret; + + if (!(*sr2 & SR2_QUAD_EN_BIT7)) { dev_err(nor->dev, "SR2 Quad bit not set\n"); return -EINVAL; } From patchwork Tue Sep 17 15:55:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA07C16B1 for ; Tue, 17 Sep 2019 16:04:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9702C214AF for ; Tue, 17 Sep 2019 16:04:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JFSzhsyQ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="oZ9ffEDs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9702C214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=si6s9flqZhiiIch/73AJZQUp80JICQldgj7UgOJGWKc=; b=JFSzhsyQj7UfWc i9H02WzJslptEGZ/SqFFVJKGUxggthmZa9VPWJDJgglIpu5q0e5JQQXCvcuRIXv/vYiVq/wnXnjAP U1jHg86ECWw+lFwt4Irtk96SbMdg7vohp+ozRsSZQRsANrPEJWZ+sRnT0KjDTtyhldr9y2iW41dS0 d427fAW1qubfCHn8VKLvEStGKHqrRqelw/DCaaCPeJysOmaSCIGMyWKE9QeEAaAkZNQW+IqwV/OQy JorkdeOG310qww7dG+4d4k1o46vgiET+5t3rv8PCrXj6WiNdb1vnxvo2QJNneBqA8zJnyge5WIjob MnYNQui+m7I4B47Vha2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFxn-0007o8-6s; Tue, 17 Sep 2019 16:04:23 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpE-0007sv-GE; Tue, 17 Sep 2019 15:55:34 +0000 Received-SPF: Pass (esa1.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa1.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa1.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: V635VAapn86RWzgJFirnhBhzoeC53ADoj4zZvwshLM0ziZmsDTTOQEEaZZ1/25w76LMoyTgsRJ ROFyli7JjwIAEC3LJ/ICA/sv5JVdLEzeq3ynkGW0t2/DAxR3DQe1syiqaAdvDPkobph3zGZIbn 9pw9us6ddGEoB8rGgeVesJqq/riyDVxaiIUCb79P4gprHTXd7EncmmoDjS/HyjV3sjkEp0wjJH t5hQfbIlPtJpT1ptmYxZWKmvDvqnsJjRQSv+SiqenyzQYhCnhAqxNUGZM1aUtSAg0eOuoAXIx0 roE= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="50797902" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:31 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:28 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=icVwCYGyUmVVphb+WxWUvsJPvEK8swDaV5mchKgLs/taiggCVbokSfnx43g+CrAZeG4DwsIxvAQoDHrfuiMWS3sEjiBlR0pTkgWcshySgQI/KDwIrB7fZXP+FJN3FMCv/5vXoye6vPxGRoXsNdmxL/bqM6sq89C0QlH86mRm7ELtkcRxEdNctEpc6lvDZNU4bZIEkpXoClmMcqEFwncgKJGWf8bNxHYcnowFVo5m/RXX/dvSZ5G2m+eCNo0XkZizadE2FBbkDkDsf0EfThHfq0nrwYBX9A3B0RXSTnp92qujDlOpImh6SONVvsuJSyOp4eWi1fpfhNuOo90758H+ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1JzIz15MQ9vdHd2NwVY1HrpfTldHjrl66+T2PZZcLCE=; b=XDQn28/PqquUYvkp9urEC2typjVXIX4E2YznAZNgUwrdSwzC6Gix0lmPpNZrRFcTP0lswM43Q1racMn28w1k8rAFsn3HYJ5z748g2UD07MUiIvoW/R8A8B9jiI8tmXxaYnSQb9G6GcWiKO4+8rtaBRmeMtuEUmtwDf04uD42BO4fkRn4tgdtRfuptsOm0/xPcV50b6JsOnelqLxYC6Rvf6QTv54G9xF9Fb+BmyFRePXryi36GoGFvhGIqlluFHmgMigQwwCC01rmEqifpP50etlXLiXeSRy5ebhvQsy+bmQsvOnBal8kKs2bTQkz3rBXalx9gFvPC/qqq8nK9t2wAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1JzIz15MQ9vdHd2NwVY1HrpfTldHjrl66+T2PZZcLCE=; b=oZ9ffEDsvQRSiAbiIIu32JbOB3gM4ltFmq1rRddNoWVovpCRsEPtvI/VAQNR1rSy/P1OJB3Rw0T5CyxV3lNsQDFbnf1cnvNsXOGu5tDMWd7ehx3oykarf4l7mxcl0IBPeHsN4DS13XfG+5gakwi7WDz5YX0FaaG0JLzVViZ+M6c= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:19 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:19 +0000 From: To: , , , , , Subject: [PATCH 12/23] mtd: spi-nor: Report error in spi_nor_xread_sr() Thread-Topic: [PATCH 12/23] mtd: spi-nor: Report error in spi_nor_xread_sr() Thread-Index: AQHVbXBOn4bEa8IcTUGlZMo/2pu78w== Date: Tue, 17 Sep 2019 15:55:19 +0000 Message-ID: <20190917155426.7432-13-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3cd80f63-23e1-45cb-cc2d-08d73b877074 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: qlGX1dM3L1Dwmk3fJ86KlfFRrHpd3Tx3FHVNAYnb6YXofbowXr9vO8PZzOwOCxnXO4LKCOTXfc5Kzdx76O9pZOdmwOFlyplgKlUYnRX7ls0UrQJsi+unZ/N94eEBkKveOuqYtwSY5eOfavamPqoPegW2PaR2frzmbBFlBOF0+SJB13xur9syZvqqrHjSqDr1/J7WAnhLGtCglSfpjYG0c7C7R07C5cJl2m0Uy0F/1OHWsBieknJ7jm77s4QJwvIKI9gFeUsRK3NIrM8LokUY+4IP2YLYUwyIdm1T4sSh6S6k+oLOfc3m+bd+zsZh7uOyU6suHk6SBiIP3XXU4XeStSru+SiqQ3lxAhKPSG/zybEb1Tvr4dVaxMmyCHbuHP4Aoe7oVeOyhmN5qQjnKFmFEi+b6XCCq9UDYuK0chVBLFM= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 3cd80f63-23e1-45cb-cc2d-08d73b877074 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:19.6656 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: f1QYb2RAf3TK2/z2m92GWjrDsJ9nKKfjV4QweAn+hMxbAXApE2Br+wuvA3N1MgLfobgvmRTc2z/Lr8V1nxBXa4vV6iLkC7NY5igRADfrgqk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085533_033639_E55B1FC0 X-CRM114-Status: GOOD ( 10.92 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.147.91 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Report error inside spi_nor_xread_sr(), to spare the callers of duplicating the error message. Add method description. Drop unnecessary cast to int when reporting the error. Comparing the return code with zero is enough, drop the checking for negative return values. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index c06de7ad6434..a34614753d7b 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -537,8 +537,17 @@ static int spi_nor_read_cr(struct spi_nor *nor, u8 *cr) return ret; } +/** + * spi_nor_xread_sr() - Read the Status Register on S3AN flashes. + * @nor: pointer to 'struct spi_nor' + * @sr: buffer where the value of the Status Register will be written. + * + * Return: 0 on success, -errno otherwise. + */ static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) { + int ret; + if (nor->spimem) { struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_XRDSR, 1), @@ -546,10 +555,16 @@ static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_DATA_IN(1, sr, 1)); - return spi_mem_exec_op(nor->spimem, &op); + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_XRDSR, + sr, 1); } - return nor->controller_ops->read_reg(nor, SPINOR_OP_XRDSR, sr, 1); + if (ret) + dev_err(nor->dev, "error %d reading XRDSR\n", ret); + + return ret; } static int s3an_sr_ready(struct spi_nor *nor) @@ -557,10 +572,8 @@ static int s3an_sr_ready(struct spi_nor *nor) int ret; ret = spi_nor_xread_sr(nor, nor->bouncebuf); - if (ret < 0) { - dev_err(nor->dev, "error %d reading XRDSR\n", (int) ret); + if (ret) return ret; - } return !!(nor->bouncebuf[0] & XSR_RDY); } @@ -2800,10 +2813,8 @@ static int s3an_nor_setup(struct spi_nor *nor, int ret; ret = spi_nor_xread_sr(nor, nor->bouncebuf); - if (ret < 0) { - dev_err(nor->dev, "error %d reading XRDSR\n", (int) ret); + if (ret) return ret; - } nor->erase_opcode = SPINOR_OP_XSE; nor->program_opcode = SPINOR_OP_XPP; From patchwork Tue Sep 17 15:55:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 662B71747 for ; Tue, 17 Sep 2019 16:06:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4142D2053B for ; Tue, 17 Sep 2019 16:06:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GKHyqsWf"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="CyUn1s5x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4142D2053B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=mXU7M1r79XUy7h5ymjT6zOJyNRbG8CEsLcoJme+e4FQ=; b=GKHyqsWfZsSSC2 07+PIBVovaRk1HW3tJxsnsc6cFV/lokcjKoEmxsfbyKWbXT7ELSLoVY2fRciqbJcoUGKh0fyRGhEr Z/qZ1esxDM9G21R7ZqDtoM2B1VpHNvOcr6VpahKEUGcoCTOplDAJ4QjLYCFiops7Jfvh3ieNmvDmi fTBzkkqqdsva83vZN78XkPRXmNiMdlfU5qeFqlRceFnDWg9AmIU5FcGdNBPQ5Lr8knTrQAShkHRAb OT5VN/A8MvcoGgmw+QEvV0ZrN1+UCCiqz9kNIOSXFh6QcxlhQ+08v/tXJ3bm5jIq93UinnO3obzT/ Zxf8grJt3wR890efF/4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFzN-00029i-DA; Tue, 17 Sep 2019 16:06:01 +0000 Received: from esa5.microchip.iphmx.com ([216.71.150.166]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpO-000843-5Z; Tue, 17 Sep 2019 15:55:46 +0000 Received-SPF: Pass (esa5.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa5.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa5.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: sbHl35Z7i/YG8H/U1vaP5cCZMmwcbm/UkTS5ps/FmKZ4jP0m37xAAmt8z3l3Y51JNIZqK3jW3R BiO+fH/sQEk9XnwoDS4ROreaALs0xPGD3gdbtJiRJAcyuXmBmL4fAzX3QYSm7D0E2Tc6iR4ssF +BZrFSswpXdwXNIlluGzl8P4BYTSRwX4m34kmKyiskWYI9b2xYg8nm+vhJZGwxy4Wbh1XqFJoi WaTAfWxPcjaIFyWFDhkQgT3glBuDN4sXkyYZQK7Uwnw1yBYctyd855rPP0bX/lCWfWUQosmxfq Amg= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="47827239" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:40 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:29 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O5FcwuusetmBOozqzlt+Xg6vFofXX5fahRyy28NRyzkkCa4Yfep+J/Tl+KTDmgmBNmmLMXV3uc8dhR2UrK9KaUWlr/BhuFZr+WrA/RIwY5XVT87UPZnx7wlsJF2W8f2Fmg7IQt5U7ZbJ80UIxTbHW6gqWEOreuL/ML9ktLARwa2Gv293ahRZN9R1Z5hj81C05j9BZJlIFlGXfH+4cERvfz5KBGrQhzAjvBK5I2+wnIUFdlJq6xjHHkPU8oq16nFhsnmN22V5y2Nt+i8piRBVRQAQZPQrjSumNwQqU3v2iPaE6+Ca6gRXcN9xMdRce4QnzRfgd/0bgbM3AXDiGJ7kdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XoyZxRMn/iylWaiKRYPZ681T4fbeFdllCjsUhPi0Vko=; b=bTTT9pKb+Hm6iDr6fyW9iQMff610bsW2X6KY6AFMQSpX0NCeRku0hRW9JOdahYI1K+d0GunDu5F/5lxyw/3ry/+EKf8WonzzsGVjyvMIw6QxfPJ+fH3OJ+yQEL4WQvjpTvT9ItEY0XryJSXr3c31K8POGqSIC1bVnMbK36RQfZ0hyHhGRkv47C51JFH77Y2drU9FuVVmMpHsaau6XmNvhmdZ4KNhL216OkzLJNP7EL0s38MFrO7txPLMNRno/qNuqhOS3NqBXi3sCCEwxTpFwzGgHqodQyhwQr4d0hFnSsA3gd+RS/ur6MqufGjNHstFewUzwdqVmoPYyApMxBk2xQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XoyZxRMn/iylWaiKRYPZ681T4fbeFdllCjsUhPi0Vko=; b=CyUn1s5x5MaFYkqiqBievNsN1eh0Q3rQ39q/A+hdf/uHftu6k7kf+glH/jaKJCo2gKutLa6FQ8cAgIaDUvKFBUlNHmQKcDnik1VB3N8oyuU5nfsVaJPUvOIiQ8JZmDIBSFGL5KTbPo3GWkOY106UxsvMgDh1CPtw8PdH00W16hI= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:22 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:22 +0000 From: To: , , , , , Subject: [PATCH 13/23] mtd: spi-nor: Void return type for spi_nor_clear_sr/fsr() Thread-Topic: [PATCH 13/23] mtd: spi-nor: Void return type for spi_nor_clear_sr/fsr() Thread-Index: AQHVbXBQQBTeia0F606dNDOJ27F+sg== Date: Tue, 17 Sep 2019 15:55:22 +0000 Message-ID: <20190917155426.7432-14-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5ce87190-9c56-4d3d-b9d6-08d73b877298 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: +H6JyNqliVshFO2OBCBhUpNZa87LAymlgSwuP+iSX4RTWCVPvTwW61X+HpnqTwLSdh7SVm/Ow1KYOzF4sHYUL8ZYAv/Ho02N+Kh0Roa7l9p9JrFer7yuqew7LRlmenJN2wCNxMR5HeVceeEXyNrUUuHuhUDuJ9mVPDs+58KkPfRrXL2iuN+4QV3gi3Q56T6hZTZ88e3j3n1rUgtOkGYjmAEuOkERLWWsTHO7Ky7brO6t9wkgg0df4eIqA8lvBZAxjAL20R0mfRL/UCgmxOCaurHrdpyWws2v0ZzUdEOWWw3JAhtIds+BBfUSieICbpIP50Y5lAfLgR+UqGwI2kqTUxDO5wQXk1LyQCF7WNZ7Jt9IsS4Hufuv/PIxP3Kb+G6bdcTZdqAC9X3ykUWS0OKLru92BtLloIozSEOJliDI6Jk= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce87190-9c56-4d3d-b9d6-08d73b877298 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:22.8688 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wpymbBkB7XV9jIirOHlAtEJ1NQmntWDreltwJofuMJ493iw0SGXrwWQDLOXABxJL7Nc6Nr2Y0ZYuaeEGGOrxyfOx9/mTEvPixY9o3oPsCy4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085544_273173_2D166F3E X-CRM114-Status: UNSURE ( 9.17 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.150.166 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus spi_nor_clear_sr() and spi_nor_clear_fsr() are called just in case of errors. The callers didn't check their return value. Make them of type void and print an error in case the operations fail. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index a34614753d7b..62b9298473b4 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -578,8 +578,16 @@ static int s3an_sr_ready(struct spi_nor *nor) return !!(nor->bouncebuf[0] & XSR_RDY); } -static int spi_nor_clear_sr(struct spi_nor *nor) +/** + * spi_nor_clear_sr() - Clear the Status Register 1. + * @nor: pointer to 'struct spi_nor' + * + * Prints error in case the operation fails. + */ +static void spi_nor_clear_sr(struct spi_nor *nor) { + int ret; + if (nor->spimem) { struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLSR, 1), @@ -587,10 +595,14 @@ static int spi_nor_clear_sr(struct spi_nor *nor) SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_NO_DATA); - return spi_mem_exec_op(nor->spimem, &op); + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_CLSR, + NULL, 0); } - return nor->controller_ops->write_reg(nor, SPINOR_OP_CLSR, NULL, 0); + if (ret) + dev_err(nor->dev, "error %d clearing Status Register 1\n", ret); } static int spi_nor_sr_ready(struct spi_nor *nor) @@ -614,8 +626,16 @@ static int spi_nor_sr_ready(struct spi_nor *nor) return !(nor->bouncebuf[0] & SR_WIP); } -static int spi_nor_clear_fsr(struct spi_nor *nor) +/** + * spi_nor_clear_fsr() - Clear the Flag Status Register. + * @nor: pointer to 'struct spi_nor' + * + * Prints error in case the operation fails. + */ +static void spi_nor_clear_fsr(struct spi_nor *nor) { + int ret; + if (nor->spimem) { struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLFSR, 1), @@ -623,10 +643,14 @@ static int spi_nor_clear_fsr(struct spi_nor *nor) SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_NO_DATA); - return spi_mem_exec_op(nor->spimem, &op); + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_CLFSR, + NULL, 0); } - return nor->controller_ops->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0); + if (ret) + dev_err(nor->dev, "error %d clearing FSR\n", ret); } static int spi_nor_fsr_ready(struct spi_nor *nor) From patchwork Tue Sep 17 15:55:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64D6014F7 for ; Tue, 17 Sep 2019 16:04:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4203A214AF for ; Tue, 17 Sep 2019 16:04:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gLr7ig4p"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="SlMPsNn+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4203A214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=cNow8BTqD8N2Sqs4RPRE6DDs017TiGHPwikXnkm6cmk=; b=gLr7ig4poDXl1y BayovZ4jCHPyAyA3y/TirrWDlNDXX3k69kvWJUeulqemmrhgygzZyJUjrc++bT/AP5FV1Prpz+Glc UWCdTWzdBiaaULkwVvohWACpRGNnckbnUIapy1YlWKUPw/NdCo4g7//A7TzubxBz3Uf4YA71N1LLs MUpQmhXm7Sp6HTmzfhcezoy57k1p9gKaDZOd0cPhsmvCI4VIzd4Vfop/zuUzMITQY1GyOqPymri9y qfkjrWeVE18jRd91K996UQV1sVnRZF4R7dDIFbRf59YVDXOz5kcQm/j2F9c6Eqz4XVpTo5a9a/V+9 FptqeG9CSiIlRTT3433w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFyG-0008Ic-Dc; Tue, 17 Sep 2019 16:04:52 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpF-0007vb-JB; Tue, 17 Sep 2019 15:55:35 +0000 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: W6e3A3urWHfRUtE5GbDbHhDSm14ypSq5z8iWNaLLxIz4RA9Win3pcAcFrMk9BnDI0I5TD7IuE+ IBQjTG8grs4QCf0F9mS/8Cuun2BjNuGGG4eEsN1bn9BMIynXW3+8tCnerMPrhFHfTGzg9iwLBn PT0f/p35s3wBbSpT7hXIzrD4mWLqaOAfthAveUKz3gVXRTyFBts1/oEZ84mGNnw7sPjOGsOhEM gUjew7x7ob3f8rHOMlkn4O3ngwLTgcTVaKleaikyGZEfrVz2b1EJUUJ3Sntyedfo2gpJ0iJK/0 D4Y= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="46517782" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:32 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:32 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cSo/k/wKKEKCQAogFQO8KMbLhmv3KunaU2Yr89/RFOXd8AS7PiTqZnxvwHYukTy88MEt9f/pjYA31+uvcveYYBwFb1BCojqEUbXmFJzxasKbluJ2+vnHq6/9J278UWMF4ktMqfdTDC2oWIkhXPOf2WhpYnL9z0G2SzIlBThW/IhL60Dmat+WUlkPjXDg70klBUlj4a+rW7Xv3wwilT77ColOc63c6aXmUQBJb8DTz45y4hAa2Ug09zA7320lHgxHj9vaf5D4iHo4D9LriMaSSFusi4KviCFouMdmK6JjRfKQTGpQ8S8d5XGz5Ebijqq2ZbA0l4S7BeqoCWDz9QHbpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U5/g0lwApDKVGpkmk3ZFMtF7NqjQRER6QfSnVFEfA8c=; b=XwHEC1mdo6V2ERSg4fSgV0HWCdRbuY04fXpqjjHhlpv/HgHb1VgqDjpJgDlLmvlCmRUSP43tKANWdTxh0Zk0LvDuPcADNuM4MAst9cEe8EocbnnLB1Er60i4SlTbeYptaCc+NhVDtxLI2HvynP1H2kZUIOI603BiwZ5uOT5tJRBva7ohRMeUwTIbjdgE+PVyj05vpwcWtjNFJAS6DecdykM9Awei4qjNuAZ193H4P12PoY07ODQDt/nYyqwpKP99rgz1DDEArGqWGa/cHm+KfqjeLCqyhVKWIrMt1tyxwJ7h7cLuUkhphW5QQR0k7b03M7jeNHz2Z6AAwc+mPInJeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U5/g0lwApDKVGpkmk3ZFMtF7NqjQRER6QfSnVFEfA8c=; b=SlMPsNn+0pBHHD47LcDIy37J9grJVcPGgWki4i1S1wKSqEJCCJoDn87lnq8BHR577suim3xNEPNNLSA/HlhyndpAmhI6WMeAWuXokatq4UTevhXexwhYYljHnetThJD4jUV6QNwRlqPDR9LExQEYpalnATkwi1pE4UerTOktTOE= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:26 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:26 +0000 From: To: , , , , , Subject: [PATCH 14/23] mtd: spi-nor: Drop duplicated new line Thread-Topic: [PATCH 14/23] mtd: spi-nor: Drop duplicated new line Thread-Index: AQHVbXBSRN+it9xUPUKx+lZiCnNVTQ== Date: Tue, 17 Sep 2019 15:55:26 +0000 Message-ID: <20190917155426.7432-15-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e7a2e377-9195-43ba-b09a-08d73b87747b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:262; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001)(4744005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ReqTEVTBbIT0q/cmXTdr9pWYAdqx0YzzJFidkakULJtFLcHra2cxo22x77tc4ZqxSjudsq9gDziKk5SyNeq2mYBLsYTpCjqzAMIf+Ph5I2Ae6wA9se+Va0j4axnFA9li0q9RE9qI7Jc6wkHtThDY0gHn+bHLpB1e9tVFgz8ZoGOntkwZztheM5TT8R8TSs+aTMpE/giENPJL/Pw1zml1vBOrPl1yNgMkD4A1U39r5nrex/cF7MAz7pamR78LwDWbNfSMR0o2hq1IFAMRClZl6ij6hCBuZxZgmdHxql+eU/EGjEPbgw64M430feEkGAkm3OyxoKO+MoAm+2j9f4UaiEjmXISnSjR2ZswwoyLj9YbfLlcj0swqcgv6KEgauadYqgWebg9CxEzQTa7FPjXhz4g7EVP5ayYORSJGsRQL1PM= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e7a2e377-9195-43ba-b09a-08d73b87747b X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:26.1638 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: F2ae0vWKCrSB4G9fjdCppmJiE5C3cgLrvT4BYDBK5aSK8ANTKwZeESWmDFgllKHGCDIP83M0UptYgw9m7cgDzzCNDR3bbcd3Y/FlNPbMOEo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085533_899962_EA8C8B51 X-CRM114-Status: UNSURE ( 6.56 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Two new lines, remove one. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 62b9298473b4..3e4691b6522d 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -841,7 +841,6 @@ static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) return mtd->priv; } - static u8 spi_nor_convert_opcode(u8 opcode, const u8 table[][2], size_t size) { size_t i; From patchwork Tue Sep 17 15:55:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FA1414DB for ; Tue, 17 Sep 2019 16:06:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEC8B214AF for ; Tue, 17 Sep 2019 16:06:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MEdbI4nF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="aUFj2HNj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEC8B214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=61N8dzw9p07qbymJOPPfsRFwTPVgenHMFZJsraKnrmg=; b=MEdbI4nFrJYncf 0IvB4UQx2SDgyb0TMqTyjtdicPhPST+qHliZuYFraw8dxlSiqoX/z6vs6FK3ulB/UmJiCdb+JGeGR M4smwjn4XFgZpR2gsN8Zx+IsCWXy5/vJQHk56rLTsNDxVto7XrTz7lha2IP3Yd8BBVFF2CnVXNOwM /5mw8sUzoblN/uNAcU+bRzxi8UDgPhN0prhxjjn2BZaKvgGdPUitDnwgZWYB2dK8ZxyUj0mmE+hUE /X17ahDmVW7W078wBN+aUP2Ju4/ZYd7XVlaaBEaAHB3wM7aI34U6da94kDdfCJwjFxBdT2s/PZ+ql ii10oBkPfMcn7AbgFEwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG08-0002e1-RH; Tue, 17 Sep 2019 16:06:49 +0000 Received: from esa5.microchip.iphmx.com ([216.71.150.166]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpO-00084B-5Z; Tue, 17 Sep 2019 15:55:47 +0000 Received-SPF: Pass (esa5.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa5.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa5.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: 0bP76eAWU6I9XGQZ3RyDnJxDzb7Utkd/VMRV04azvJvHZOVv4DPjBl87eu+nLUezZZqubWXsp6 2W3s7FkpmvWTEZM8AjeV1wL1kAWGcVrxC6dId/jWJlh/7Gy6HeLZvU5DJLAKjIpzscRcDIM38E amd3iOUC2xhTjck1G/Wsjwpdq40OlfV8KW8iUels9cIOpm1jwBEQS5pibNdf0gVCmunY7QU5dV iDalbejg+EdNCs0Scdx+aXrFglaiY8L4049/OYLpc1KHTG9TZ1drFhemN4qCchoAqv9Nz2oyzp 030= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="47827253" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:41 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:33 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=enqzrWdDFCPgUhQavqDa2oVtUoDKi2VSL6DcGQmM29ONy1Y5JomLSganouWaVpI8WuMbucdGgt/bl4NUHN7ljFyacdgxXzlAqVKFpYJK0Yib+DUtIHmuZFTYc35iVbFi/n110mO1S80HqIAE9R+NJckziJR6ME9F2byH2KL/MJRNHKrCpOemP4T+oyoxVFlcl5EggiDV80qdO9JIu5L6uXLtGbUfTIJW7keJV2tzwAzMrLrNDIpIzV0+PZRYCPg9q0f8ibugoPu2l8JplhayI77AO9zl7AWnLLTxDXd6vvPq3kLUlDHR4TWUoZVWIOn0SuV6cDw5MGoU8adovURalw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qp04pQe83zyL6eJLDIQ1+/g6vDUYUlreHoffNQJ/GRM=; b=EB7Yo8pMnaN37zmXAxpb3CYHQqgJsN3bvYEiug2Oyi2e8tV6XjlHisT88R8HGdVspzCOjMX3F3sen2xu1ojeIxTl9QXtC0amVia6fO09ZP7xZ0o+H2LDFuvuex76plqkDu/92wIElroaoEvhMVr+1WP1O2qdM+7x5bKE2Sd7J1Axf0rVh1xMrfqLVQKRcS4Z16awk6s5PBIyu30OtzeK+aP1Ooyx+F6iwYLs7KCurzek4NA5Ke+vzYuRW6lYBJb7pihYWc71FFn2cngIPeU5R79YATMPhD1szJGrPYMgfs/jNHAaIKkkGDDHMKUlsAv199K/ZOKEgeR8M6rwnvNB0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qp04pQe83zyL6eJLDIQ1+/g6vDUYUlreHoffNQJ/GRM=; b=aUFj2HNjX8mNTNTX55p3mXPfaiS1BZuqHI1zd74l2uzIw/YHpCMa1qei3BzDRXeq0WEYEwye0p19I1ZJwQFcTUNxeFsjbXhtJDi6bBICEoch8ERlx63QXT5Y5liPf0Z37VOIpvAq/Fo/tdnOKKkjLU690abJJwCGwcFwitgmZM8= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:29 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:29 +0000 From: To: , , , , , Subject: [PATCH 15/23] mtd: spi-nor: Drop spansion_quad_enable() Thread-Topic: [PATCH 15/23] mtd: spi-nor: Drop spansion_quad_enable() Thread-Index: AQHVbXBUqv6ofYtbZUGORBOPLMfTVg== Date: Tue, 17 Sep 2019 15:55:29 +0000 Message-ID: <20190917155426.7432-16-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af1bcc92-0c8d-49a4-f422-08d73b877670 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: KPfV3iLZXbdGzhgWTHElvrqfzWJbmCKW5HTxK14+301Aax4HrjjGxCZynFXQROWTNeseNCx53xPL+XRq9rMzynzyXd0aOw5z9i8aMDLjJknZlgPo4dwrhzXPwX7O8M3vWhOZZGKaJAnAMvrcO+/MrGMUKJ1/pNToCwSzP66NbH+6aaQPpaTaXEjJu5EocDQCO7KSMpJdlq+3DBBrHf0+hddyzTRmZl24ZOKaKgDwo2J70gPSn3whhVTlYMOiPeJFcKHZKUbArSEQZcQkLB9BEqN0gRDP+A60OZTK5YdPVx4pLr03BGE0n6R9lat6tfhnwtYX8s2T6nbkPM8Rw4Q7ctnK79DMtJ+AiW8nSNSwdL701C80Gy8PGU0dew/STP7zee+t/Xkpms+JiypIwd4ojYGL/TLJ15XhwbT/WQJ84Kc= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: af1bcc92-0c8d-49a4-f422-08d73b877670 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:29.3220 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MdkXPHE7kOJ2m700WPC/hFn3tKzScY3xuY/NEDp40YTOc5w+fn6r8SzGEK7+u261RE0CmVSB2WfsP45nDl/xx/zzchms9HnIVSxQF0k87EA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085544_269940_D9786C4F X-CRM114-Status: GOOD ( 15.50 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.150.166 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Drop the default spansion_quad_enable() method and replace it with spansion_read_cr_quad_enable(). The function was buggy, it didn't care about the previous values of the Status and Configuration Registers. spansion_read_cr_quad_enable() is a Read-Modify-Write-Check function that keeps track of what were the previous values of the Status and Configuration Registers. In terms of instruction types sent to the flash, the only difference between the spansion_quad_enable() and spansion_read_cr_quad_enable() is that the later calls spi_nor_read_sr(). We can safely assume that all flashes support spi_nor_read_sr(), because all flashes call it in spi_nor_sr_ready(). The transition from spansion_quad_enable() to spansion_read_cr_quad_enable() will not affect anybody, drop the buggy code. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 58 ++++--------------------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 3e4691b6522d..20d32b7db268 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1869,54 +1869,6 @@ static int macronix_quad_enable(struct spi_nor *nor) } /** - * spansion_quad_enable() - set QE bit in Configuraiton Register. - * @nor: pointer to a 'struct spi_nor' - * - * Set the Quad Enable (QE) bit in the Configuration Register. - * This function is kept for legacy purpose because it has been used for a - * long time without anybody complaining but it should be considered as - * deprecated and maybe buggy. - * First, this function doesn't care about the previous values of the Status - * and Configuration Registers when it sets the QE bit (bit 1) in the - * Configuration Register: all other bits are cleared, which may have unwanted - * side effects like removing some block protections. - * Secondly, it uses the Read Configuration Register (35h) instruction though - * some very old and few memories don't support this instruction. If a pull-up - * resistor is present on the MISO/IO1 line, we might still be able to pass the - * "read back" test because the QSPI memory doesn't recognize the command, - * so leaves the MISO/IO1 line state unchanged, hence spi_nor_read_cr(nor, cr) - * gets the 0xFF value. - * - * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI - * memories. - * - * Return: 0 on success, -errno otherwise. - */ -static int spansion_quad_enable(struct spi_nor *nor) -{ - u8 *sr_cr = nor->bouncebuf; - int ret; - - sr_cr[0] = 0; - sr_cr[1] = CR_QUAD_EN_SPAN; - ret = spi_nor_write_sr(nor, sr_cr, 2); - if (ret) - return ret; - - /* read back and check it */ - ret = spi_nor_read_cr(nor, &nor->bouncebuf[0]); - if (ret) - return ret; - - if (!(nor->bouncebuf[0] & CR_QUAD_EN_SPAN)) { - dev_err(nor->dev, "Spansion Quad bit not set\n"); - return -EINVAL; - } - - return 0; -} - -/** * spansion_no_read_cr_quad_enable() - set QE bit in Configuration Register. * @nor: pointer to a 'struct spi_nor' * @@ -2071,9 +2023,9 @@ static int spi_nor_clear_sr_bp(struct spi_nor *nor) * * Read-modify-write function that clears the Block Protection bits from the * Status Register without affecting other bits. The function is tightly - * coupled with the spansion_quad_enable() function. Both assume that the Write - * Register with 16 bits, together with the Read Configuration Register (35h) - * instructions are supported. + * coupled with the spansion_read_cr_quad_enable() function. Both assume that + * the Write Register with 16 bits, together with the Read Configuration + * Register (35h) instructions are supported. * * Return: 0 on success, -errno otherwise. */ @@ -4560,7 +4512,7 @@ static void spi_nor_info_init_flash_params(struct spi_nor *nor) u8 i, erase_mask; /* Initialize legacy flash parameters and settings. */ - flash->quad_enable = spansion_quad_enable; + flash->quad_enable = spansion_read_cr_quad_enable; flash->set_4byte = spansion_set_4byte; flash->setup = spi_nor_default_setup; @@ -4776,7 +4728,7 @@ static int spi_nor_init(struct spi_nor *nor) int err; if (nor->clear_sr_bp) { - if (nor->flash.quad_enable == spansion_quad_enable) + if (nor->flash.quad_enable == spansion_read_cr_quad_enable) nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp; err = nor->clear_sr_bp(nor); From patchwork Tue Sep 17 15:55:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7134414F7 for ; Tue, 17 Sep 2019 16:05:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EA76214AF for ; Tue, 17 Sep 2019 16:05:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fBBYsEOu"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="lxcrKxIF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EA76214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=pb6vQBXzGgQfJI1jE/XUNgDlkYuL6WMVo2M08t8sxd0=; b=fBBYsEOusjDNWE xLCvlD0FzS2CuqsycGF6MbScirHSVbCbv4GFFDA0OE3JCwcMIBNFiz6SbbNAvO0uVoypcTwe897Ny 9WI/XDpyMxl+buqezy9UmM1DbtrXx6/px2uYplxDsHg4Hdv2XAb/3ciTDerRldVSrnDpw+fEKZL3E VF1O3h+ygT2+/SeQE+uD1QoeJkfateZ/4G4mtyKx/IGz60JExQ92bq6U2iWIc+sqBkgD0O/+FJn5s C+LD+d3JyttDPIzvlJDopoNxOaxGH6UGruLWZmEgfDUHd9N7p/Q9XUY8IZgvFgY007xHLorpPokzf UqarOday2qZQfRx1OSng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFz3-0001tm-Sa; Tue, 17 Sep 2019 16:05:41 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpO-00084F-IN; Tue, 17 Sep 2019 15:55:46 +0000 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: q5WoxqXfQ3OzCXo/70w7AwtRyzKxh94mJuolg4pevnAdlNP2wRGTdpvs2gVVPzB8/TLdOFjcBA h6Lx2mTx0PpqwAoV7NI7YAUbiBTXCse03fzcJLEdJ8rcBuwd2jsbhMUNPq2yEYpwkx1jnm05ZW E+WsLJ8nZAjLG/vwW/yXZ2aGQRZFC0KtTbGocU9JclB8FpxYPojTBpH1cn4beYbKzD9cS8jCxe ApOH+SyPpOJpyHwOckUjuoZxF3alJ0pO1oo1JqyCCfau+VU5zAhujOGWftp0nq3pkndado3F76 cTQ= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="46517800" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:41 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:35 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KVcdxrDsgWE+KD7myC7LOWPu0Mv87bX3a/mPHVRpU9tHeRfpTQTxZpMt1RxApWl6MBGlRg6KHn4r3+Ngd1Q+37LQCtm3MV4n2B8akE9huCkwnUgYsMSbb8RYHnrOz6EWIlCb8UesjXVxQPPVERDjnGnPCO9tvonBM9uBhu4rg1mDpZ0srQzCb6Orj1lrUX1enFBDe+ASIbuX3vdJhp811bAjAgN+vmTbocK7jNh6dxCumxgdVGJgrgAACoB2Qez7F5dbzkoyHzyiHAMJjQUBvhMA+F+R19XJjEtRuXK6zcwTi8ZR6r8F/T653RNrqToD/5oONecqKnG6y9ZWsN3HDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YBL7iguiLlSDqFSs5hLH0kmhMZIgle4FL89EChz1KT0=; b=UcZdPcFMiAZb6tfV9PMIQemmm/A7SNUFkSpMpMwQPYoS9XbwCDiJ3wPpbEzv2ggMhU/aG7e59oN/ZQimfAU2L65uZ841ZUAJlpaf+xFVAQmmHhSOib4ZduazvbDmtQxxFJH1+RuLAW9r0zJ1hDHSgx1pGbYNKCvb9JRjRn5FyS9rajxhu34eUz1A9efYBWQXynplSSV79bdu+VhL2wmS0J6Hg1Btljox8udEXXxbtUnoYrDRKPsAUlXrNeV6NKBu/srpQmxKpdTL0sGPlo8ORsG5/jAxrsOtVW5SD94peZnmzU2X5wfx2pbMTrFO6eL4CmZ3GC7rcDMtw+tBUdIGmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YBL7iguiLlSDqFSs5hLH0kmhMZIgle4FL89EChz1KT0=; b=lxcrKxIFweexjjVGZXzLpHeavvZ7FXka4kG8ifFY/K3ix8QQZu7cfG2Z7iYrwZreqbPFJ1JGzDlTh1vg8xae/eKX7PNV7lkeLIbTF/eg4VBIDQ4w9WajC7WOnzWyiKvlTWdgSmYeJjD3p+UCXW/V5aNXO1gehOR8jYqKddkjXBU= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:32 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:32 +0000 From: To: , , , , , Subject: [PATCH 16/23] mtd: spi-nor: Fix errno on quad_enable methods Thread-Topic: [PATCH 16/23] mtd: spi-nor: Fix errno on quad_enable methods Thread-Index: AQHVbXBWK2z2ghqXAk2rbgya4YOWuA== Date: Tue, 17 Sep 2019 15:55:32 +0000 Message-ID: <20190917155426.7432-17-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: eabe5cfd-42f3-4d89-4a45-08d73b877855 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: aHLH4Aq+wWbztE2OuFXntWxKRSvEwFl2UM7MaM1gDMs3wXamfIAYj/hzYKJ0DbonHjsW6TenraWCV1Ml45CpNvuh+heCJm8jVxHZ3KO33P6h3+rol5TT5Txfpy25cTXEyrOk98sDx32QB+dIAevwMyQ4rLb5STDR8UAZ+bOhDNmUDBq/KlsXCn6vzRIGgcqWSXybTYTXJK2q25W1IkvGcEom8q+HBxwx/M9Kr17cBnnr/LCL5ytj0Ip3dfzrPIac1NxdR2UGOWAR7GKghgXyU1HciQG3F/OfYkXpObAJrLXRgUk5b+KwOlUEAq4Y7thG6y2JDghRe9h9dnbBdxDzUnfQphBNAYzym7EchkxPRfnizfzpvZ6wSNCfyi6O/9qGcyCyUi1Oe0+5lKVbnB0tpKjWQZhB/iub4m7WElWEq4o= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: eabe5cfd-42f3-4d89-4a45-08d73b877855 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:32.5671 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qW3BmoKn73Q/7p8babo6HX9bRg6+z9Awxg7zIPty4BOl+VOOvi6VPImbuXKL//HwBp6VJ+lqleErhND2Bd8n34U9dRxR1YyBWtzGAFJJJR0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085544_269718_DA013961 X-CRM114-Status: UNSURE ( 9.02 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus When the Read-Modify-Write-Read-Back Quad Enable methods failed on the Read-Back, they returned -EINVAL. Since this is an I/O error, return -EIO. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 20d32b7db268..303a7bcf3423 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1862,7 +1862,7 @@ static int macronix_quad_enable(struct spi_nor *nor) if (!(nor->bouncebuf[0] & SR_QUAD_EN_MX)) { dev_err(nor->dev, "Macronix Quad bit not set\n"); - return -EINVAL; + return -EIO; } return 0; @@ -1940,7 +1940,7 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) if (!(sr_cr[1] & CR_QUAD_EN_SPAN)) { dev_err(nor->dev, "Spansion Quad bit not set\n"); - return -EINVAL; + return -EIO; } return 0; @@ -1985,7 +1985,7 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) if (!(*sr2 & SR2_QUAD_EN_BIT7)) { dev_err(nor->dev, "SR2 Quad bit not set\n"); - return -EINVAL; + return -EIO; } return 0; From patchwork Tue Sep 17 15:55:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6338E14DB for ; Tue, 17 Sep 2019 16:09:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DCAD206C2 for ; Tue, 17 Sep 2019 16:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LeCAxoOX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="HmgDdlbc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DCAD206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=M7W6TgBkwl0dBpCF9Ev4TwMvwyPS0mJypFktXyXffUQ=; b=LeCAxoOXYgJ2xI NlZe9wK8bpmOinSZGqd7kBFHj3Tu4ETsCmcFeAho7NUpUPZJFBDLBsjHWWd8JDxVGQlrTynZdyrLG H5Yrubh55x0xvvDowFnY6LcgQL8gyjXIKgb52MPtY4RaNmh8Lz2mgABwvqokMTNcVWt49Y9ouvlnN JarbZFIK5/T/6SKTWvSHnP7avgjAkCLmSYptX3e5iVUCCvwq1TsCWfhDerAC3+xbLn78V2qdIiflB Wp91DVMTB7/SHLI/Jfab2CbE9CcOP2zLJPy6jBqcPI+SfaWmUGpLTxKlZBAaDfjq1FyDW03Z3RZNj iwGKfBMNAxs8Ql+Y3wXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG2f-0005GR-Mh; Tue, 17 Sep 2019 16:09:25 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpP-00084M-4H; Tue, 17 Sep 2019 15:55:55 +0000 Received-SPF: Pass (esa1.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa1.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa1.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa1.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: H9I7MhTz/36Pub9gDzNS/F02QL9HsbEvIxXMixxogAePdmi9WcVEfelusgAS536qf48ei+8p3F CPFryjGjWqhwsD1QDnELxGvdzBWzMxYMgd5bjNomfHCWfNmTebqhgToB69dsAQ07oZlk/zwANv qhDUodZ+VVIrUl3kXuwRYDrPxG5B+N077Mvo82nsUZKHIoNt9cfYmQ7g2FZpmjaHibsFg3iXPA VQ5dHcZfme5OraCNd2z8GI6dnNWeKRKvkknpPrx9HdxuyZi2fxWNnvALb7C9fHoHnyG1N1pdJn MKY= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="50797952" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:42 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:38 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IXo6z8N9/V598ilppFo/22pkYkDZOGBozOT1kQd2X0r1bM+jIHP8O8Jh05Fkkjfk1jamdJ7ILaE795o8cFWrnQkBPLDDzvIAeDpwz1lLFDexdoBYYWN1snceFo/cSV9dj1hd0iMhi0umfFKZSGPOJZsf9OjYLlwuOyUWP/+HDzkpiqCZbHiULDoi9udT+hkkBYIvmZQmr9s6yAO5LOirfCh7PGTGbbcfEgX8n9cASIIJn78kiYveKFg4Gb1McAil4dR+5Q4ZcEBFwne6lW34czDVLWUMZerYm1JpJHbEiu0XpRId7LhYfEwdOAWTFPOqfngENe0GQLeOwVuH0/PjbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ml0az2zd1ImeeMhwaZAOFfuoD0AXepiN6KCiBZXges=; b=mhDdi/zbGtWapxpfIsIEU01pz8lLL84Au33YVhhCz94lN9rGcdRgVJ6eZrNB0N30MRK+bB0PEnRONRUTK3inBZSHjDekGQbeFikByDYGj3eHPWQLIJaQv4APBfdJBnHq9Ly7UWqM/ZQHeA++lGcfeKZuJpTwp8ls7Ss4cm5KZAxKRSM1E91GxGDr4Vbtww5FrPzeoZt7yzy2OzaHE80LXYV+sIhPZBmFhSKfgvLlhbphkpv3xIjF6KL5+F989dP8o/JJqbcC6pwn3KZblgljTXmxCAohvSxf8tdrAHZaJ9fj2efISecp/gEYa6QPljIHMn6MhfC3dj0BqcOk3yINTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ml0az2zd1ImeeMhwaZAOFfuoD0AXepiN6KCiBZXges=; b=HmgDdlbcJNbEKs2tz78sMphH/xS87g9i/tjEqgI9A0nxM2EHhBrC7+k4wjGQ0ifoURY3Qa3hXdqqAQeJOc+VELcbHP97IWD8DBdlW2NPxSY3rWiJvAfTSNw5ixauCncU66gBfFV0Kx/ArD/qn28cTSwtP4z8mKVvJ4LDMk73GO4= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:35 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:35 +0000 From: To: , , , , , Subject: [PATCH 17/23] mtd: spi-nor: Fix clearing of QE bit on lock()/unlock() Thread-Topic: [PATCH 17/23] mtd: spi-nor: Fix clearing of QE bit on lock()/unlock() Thread-Index: AQHVbXBXffWwZrBoIkKrGGyrhA4/GQ== Date: Tue, 17 Sep 2019 15:55:35 +0000 Message-ID: <20190917155426.7432-18-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b9009282-d9c6-4076-51a2-08d73b877a42 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(14444005)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ZbUdwpGGRw1omk4ci2mM/aq1ZRBjZJoddPVd3v5awYgr6XEgCzlG95xnpKviln6Kyev1bcbxRQUP5u9XFTV2HNaCgEbjdBAoIrf8TzVAv4VhuHcbyF0+I+JQF9DOrw2cZJjuVNO2W/BnA9LxSKOF06SAXY87aV7eOZbpibmoxddqxjgp8FM/Qww4Ii08rOMaScookBsJxZP4qHOoVjJhvfJhzwAgNDeddLDchq8iMFXe2o2iCEpMFOKETxZyUk+yDiaqYa1iOVhY0+fLQPWFBAdeUfJsaOFd/jNd6JMkV5DDYFu7lpnjnTFWeSmSgqDwmmur55pVjxTNR2ydkP/PQ9+VDswB+hs5UC5/jwR/dtEvODKH+kf/C6Fly2OUmmIR6GNMulbALrKT46MZKMvun/dDm/d2AexZNsIX3p1RW8k= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b9009282-d9c6-4076-51a2-08d73b877a42 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:35.7123 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 9zO3MdIaM+VomXy2nG9jXMUBsmfwAEO5c+ZHHG7WwcJ8Fi1YtGBnei0el+o3C7Y75v04VhuykVCCMpjw0AZd3RWB0U98fGeNgPSRpLupMcY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085544_276963_3BDCD457 X-CRM114-Status: GOOD ( 18.16 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.147.91 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Make sure that when doing a lock() or an unlock() operation we don't clear the QE bit from Status Register 2. JESD216 revB or later offers information about the *default* Status Register commands to use (see BFPT DWORDS[15], bits 22:20). In this standard, Status Register 1 refers to the first data byte transferred on a Read Status (05h) or Write Status (01h) command. Status register 2 refers to the byte read using instruction 35h. Status register 2 is the second byte transferred in a Write Status (01h) command. Industry naming and definitions of these Status Registers may differ. The definitions are described in JESD216B, BFPT DWORDS[15], bits 22:20. There are cases in which writing only one byte to the Status Register 1 has the side-effect of clearing Status Register 2 and implicitly the Quad Enable bit. This side-effect is hit just by the BFPT_DWORD15_QER_SR2_BIT1_BUGGY and BFPT_DWORD15_QER_SR2_BIT1 cases. Suggested-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 170 +++++++++++++++++++++++++++++++++++++----- include/linux/mtd/spi-nor.h | 2 + 2 files changed, 152 insertions(+), 20 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 303a7bcf3423..4a513ed13807 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -836,6 +836,132 @@ static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) return ret; } +/** + * spi_nor_write_sr1_and_check() - Write one byte to the Status Register and + * ensure the bits in the mask match the written value. + * @nor: pointer to a 'struct spi_nor'. + * status_new: byte value to be written to the Status Register. + * mask: mask with which to check the written value. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_sr1_and_check(struct spi_nor *nor, u8 status_new, + u8 mask) +{ + int ret; + + nor->bouncebuf[0] = status_new; + + ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); + if (ret) + return ret; + + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; + + if ((nor->bouncebuf[0] & mask) != (status_new & mask)) { + dev_err(nor->dev, "Read back test failed\n"); + return -EIO; + } + + return 0; +} + +/** + * spi_nor_write_16bit_sr_and_check() - Write the Status Register 1 and the + * Status Register 2 in one shot. Ensure that the bits in the mask match the + * written value in the Status Register 1, and that the 16-bit Write did not + * affect what was already in the Status Register 2. + * @nor: pointer to a 'struct spi_nor'. + * status_new: byte value to be written to the Status Register 1. + * mask: mask with which to check the written value on Status Register 1. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 status_new, + u8 mask) +{ + int ret; + u8 *sr_cr = nor->bouncebuf; + u8 cr_written; + + /* Make sure we don't overwrite the contents of Status Register 2. */ + if (!(nor->flags & SNOR_F_NO_READ_CR)) { + ret = spi_nor_read_cr(nor, &sr_cr[1]); + if (ret) + return ret; + } else if (nor->flash.quad_enable) { + /* + * If the Status Register 2 Read command (35h) is not + * supported, we should at least be sure we don't + * change the value of the SR2 Quad Enable bit. + * + * We can safely assume that when the Quad Enable method is + * set, the value of the QE bit is one, as a consequence of the + * nor->flash.quad_enable() call. + * + * We can safely assume that the Quad Enable bit is present in + * the Status Register 2 at BIT(1). According to the JESD216 + * revB standard, BFPT DWORDS[15], bits 22:20, the 16-bit + * Write Status (01h) command is available just for the cases + * in which the QE bit is described in SR2 at BIT(1). + */ + sr_cr[1] = CR_QUAD_EN_SPAN; + } else { + sr_cr[1] = 0; + } + + sr_cr[0] = status_new; + + ret = spi_nor_write_sr(nor, sr_cr, 2); + if (ret) + return ret; + + cr_written = sr_cr[1]; + + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) + return ret; + + if ((sr_cr[0] & mask) != (status_new & mask)) { + dev_err(nor->dev, "Read back test failed\n"); + return -EIO; + } + + if (nor->flags & SNOR_F_NO_READ_CR) + return 0; + + ret = spi_nor_read_cr(nor, &sr_cr[1]); + if (ret) + return ret; + + if (cr_written != sr_cr[1]) { + dev_err(nor->dev, "Read back test failed\n"); + return -EIO; + } + + return 0; +} + +/** + * spi_nor_write_sr_and_check() - Write the Status Register and ensure the bits + * in the mask match the written values. + * @nor: pointer to a 'struct spi_nor'. + * status_new: byte value to be written to the Status Register. + * mask: mask with which to check the written values. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_sr_and_check(struct spi_nor *nor, u8 status_new, + u8 mask) +{ + if (nor->flags == SNOR_F_HAS_16BIT_SR) + return spi_nor_write_16bit_sr_and_check(nor, status_new, mask); + + return spi_nor_write_sr1_and_check(nor, status_new, mask); +} + static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) { return mtd->priv; @@ -1492,24 +1618,6 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) return ret; } -/* Write status register and ensure bits in mask match written values */ -static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) -{ - int ret; - - nor->bouncebuf[0] = status_new; - - ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); - if (ret) - return ret; - - ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); - if (ret) - return ret; - - return ((nor->bouncebuf[0] & mask) != (status_new & mask)) ? -EIO : 0; -} - static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, uint64_t *len) { @@ -1673,7 +1781,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) if ((status_new & mask) < (status_old & mask)) return -EINVAL; - return write_sr_and_check(nor, status_new, mask); + return spi_nor_write_sr_and_check(nor, status_new, mask); } /* @@ -1758,7 +1866,7 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) if ((status_new & mask) > (status_old & mask)) return -EINVAL; - return write_sr_and_check(nor, status_new, mask); + return spi_nor_write_sr_and_check(nor, status_new, mask); } /* @@ -3536,19 +3644,39 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, break; case BFPT_DWORD15_QER_SR2_BIT1_BUGGY: + /* + * Writing only one byte to the Status Register has the + * side-effect of clearing Status Register 2. + */ + /* fall through */ case BFPT_DWORD15_QER_SR2_BIT1_NO_RD: + nor->flags |= SNOR_F_HAS_16BIT_SR; + /* + * Read Configuration Register (35h) instruction is not + * supported. + */ + nor->flags |= SNOR_F_NO_READ_CR; flash->quad_enable = spansion_no_read_cr_quad_enable; break; case BFPT_DWORD15_QER_SR1_BIT6: + nor->flags &= ~SNOR_F_HAS_16BIT_SR; flash->quad_enable = macronix_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT7: + nor->flags &= ~SNOR_F_HAS_16BIT_SR; flash->quad_enable = sr2_bit7_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT1: + /* + * JESD216 rev B or later does not specify if writing only one + * byte to the Status Register clears or not the Status + * Register 2, so let's be cautious and keep the default + * assumption of a 16-bit Write Status (01h) command. + */ + nor->flags |= SNOR_F_HAS_16BIT_SR; flash->quad_enable = spansion_read_cr_quad_enable; break; @@ -4515,6 +4643,8 @@ static void spi_nor_info_init_flash_params(struct spi_nor *nor) flash->quad_enable = spansion_read_cr_quad_enable; flash->set_4byte = spansion_set_4byte; flash->setup = spi_nor_default_setup; + /* Default to 16-bit Write Status (01h) Command */ + nor->flags |= SNOR_F_HAS_16BIT_SR; /* Set SPI NOR sizes. */ flash->size = (u64)info->sector_size * info->n_sectors; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 12961b157743..fc3a8f5209f0 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -243,6 +243,8 @@ enum spi_nor_option_flags { SNOR_F_4B_OPCODES = BIT(6), SNOR_F_HAS_4BAIT = BIT(7), SNOR_F_HAS_LOCK = BIT(8), + SNOR_F_HAS_16BIT_SR = BIT(9), + SNOR_F_NO_READ_CR = BIT(10), }; /** From patchwork Tue Sep 17 15:55:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149107 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A478914DB for ; Tue, 17 Sep 2019 16:07:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F86E214AF for ; Tue, 17 Sep 2019 16:07:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NfB3Oi75"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="h9AKQDrS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F86E214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=FVi03adMYTc++jkZa/wdCCSbnqKS0lUXumdWVYlt3bM=; b=NfB3Oi75Bl6BHm vcx9NDzkGxSpUaEHKXCO9zFSYPLSwiFOhLhw3ghKOfeqzOnh7dtJinc9V7j81eFvCijwyL6EBMmp4 iWHuhEEAJun8v2nN4Ce2A1EVB3K0hx3B+9NiBiTmnbTxTNxG0UVjApeYiZ0LeITulY178Ohp6pz2t gGJC6bil+gxR9WcyE7X6SdXd4rKtBRtpPvF+U4rBvm5FIjfbtO9QInzgd5IF4Q2O+gEm13udH19IC TV5o0cbg09qBuCzA/215tErn6Hye/SsGpXj63tNSfzZ6gCkPeNqi6CBCbGCgqE8eZjBgJMDSUTy7U Gz7euuAwzVVV1SgN1c1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG11-0003Va-N5; Tue, 17 Sep 2019 16:07:43 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpT-00086p-N4; Tue, 17 Sep 2019 15:55:50 +0000 Received-SPF: Pass (esa4.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa4.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa4.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: J2n7Vartea6wYLpBrPlGIxR2m1HzVqXQSNOnUYjVnXS5BotZ3BZrQIrslhq1R6oR6Dv0k9SPzA aNjFp9HD3m2tGN9gDP3bCnk6Ams/J8FdSknvhZgill0MxL4StHWZnq8y9cYkphJYCWTuNQWkHP wJKoxsRftV3MPzUz8w1fdNyxFTMuDovKGP2ZqwV+ec2Dcwp+e/R9PBuwwgdWm/LIywadkOuaDJ 4yAT7cuyissVcDMQcAI0gnNG/GJxJZRYDwDxU0JtX/RtqDCc+TLOZ1XDECSDUYHGY9xY5pgJjr +tI= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="48252512" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:46 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:41 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gy8OKeKS9g/lYj718tT9GoBrB8DoOtCMg0zTEnNRtGlfI70bqxk2UEpJvcWK/lY6rXTDuMmet8STeM7VCGnTBvh3E5yJOZ+8u+Lg8RUc3ULkowMmg2Ti6SZBNJyvSoFt6s+TV0xEo5BM6tCon7pEz1Ho9JSrQqTt7S/jdMUBkn6Xp+veKeGNfR/RDWnzzcw9HSAXYKT+9vsfXfdU2EKwgZ4Gp3miUdsknW1EqqwRVsd9zvn/bONZ0zYY958SpJ+iZMkHNn9gEvOMSHX0iYLNapEz0O7naLQpDPcCKAEbeY5ZpBmCFLFBQcjjY7jEO3Gb94IwL8v+hRSyTCsEhb5Bwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OKC5b7UjzUQ3SxUt9wk3LiIsa1hL7pYkjtFMJd+1pjw=; b=ZcG9WaL4q6bmZG8CTS1lXEk7r8vncI5+S99CEklfEbYIDJLeRUx+mXpGkSTMg5frB1/qy45Duxu1xO9eZU0fntAbuXsKaywrXBGoSOkcTH82yPG5WbAmI4/gyeeFx3cjHcZr4xHtofsOm0fSokO1rBrnhKH3NXxh64hnwQB1b5xmLI5nFAGJnwmB/UrC6V51Xk9YEXJwUKHvmtWSdY8NKe5YJ6uhNuoL091IWameJd2zIJiKNa+8ksM1LpF7Fxps7sT8AdhZUE2ETM+wH9ncPxmXhgwEFy3VN+y96AR9tlqdOpgQJPKNpuAU69dD17D5MsqhiPLvxzmap+mARHwg3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OKC5b7UjzUQ3SxUt9wk3LiIsa1hL7pYkjtFMJd+1pjw=; b=h9AKQDrSyWAbnQmeK6r6mth7E0vjzGf2sQxBcDhWWgRrYWic316EwQNCaVIrh5Jy5W2ct+PN6rn5sC2MQ+zkiscgY1SNHTTg8RACpY5FlsQOFmYZZMvlDQGrIhjW4lozTFsLUL0YpJHv7t6gGNWuiMdE3rcy7KG4ChmiQhqTG80= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3984.namprd11.prod.outlook.com (10.255.181.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:38 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:38 +0000 From: To: , , , , , Subject: [PATCH 18/23] mtd: spi-nor: Rework macronix_quad_enable() Thread-Topic: [PATCH 18/23] mtd: spi-nor: Rework macronix_quad_enable() Thread-Index: AQHVbXBZG9yAVdGRvkC3vecu7tUBzg== Date: Tue, 17 Sep 2019 15:55:38 +0000 Message-ID: <20190917155426.7432-19-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 15f1b520-defa-4e35-b53b-08d73b877c20 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3984; x-ms-traffictypediagnostic: MN2PR11MB3984: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(2616005)(64756008)(66476007)(3846002)(6486002)(107886003)(25786009)(6512007)(50226002)(6436002)(305945005)(99286004)(14444005)(71200400001)(476003)(7416002)(486006)(256004)(66066001)(71190400001)(7736002)(76176011)(102836004)(36756003)(26005)(386003)(66446008)(14454004)(66946007)(1076003)(86362001)(6506007)(186003)(6116002)(5660300002)(66556008)(110136005)(81156014)(81166006)(2501003)(8676002)(54906003)(316002)(4326008)(8936002)(11346002)(2906002)(446003)(52116002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3984; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 3Sgtao9C5IkAV4mkQwuXGU/gOJa2ID2j5mWxqbKXrTOLufoQ6i7/rVrYy2pjBmJ6tX1W2L8BwzCa6vKQyaz05bJmTFFyKLY1KtcLpc4ENxPPFEHBmaMefxjIjsYeJSYUqZlWzJJs9xjqYQacqrSMd0V5rbcJnkoyy02rHLM4xZbf0zGv2q1ZaaOMg28k9g/7tYZOZ8cGSVLxl7rehWjgMhfkvsG31fabjLEbc2Ff1FDn9F/02nPiGyhooverlH47FS5tdm1IGZlHObW2E0/STDQZg4+pJrpx85Zw2dP+buDofAstZb1Q7Y9IaNsg5/yIP0IynVnGI6BG383G1aHG8noIuy864ar3ErdQjQMn3flrxxavGXxFNpYXg0TYKhgG8abzJxRrKLCf+0XVBbpGxlN5HA3/adXmFJa+v4gdRrc= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 15f1b520-defa-4e35-b53b-08d73b877c20 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:38.8204 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4s6URAcG5SJe8UhN08LZ8jppxGQKmkWg1BWHtEFI4v7HQfuzBRWfMyAuM5CiOL1Lq8qDnm2BHVWQ+kESNPRJmJuxBY4032PCizjYK60X6wM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085548_800072_AE9DEDA3 X-CRM114-Status: GOOD ( 12.96 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.154.123 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Rename method to a generic name: spi_nor_sr1_bit6_quad_enable(). Use spi_nor_write_sr1_and_check(). Now we check the validity of all the eight bits of the Status Register, not just of the SR1_QUAD_EN_BIT6. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 34 ++++++++++------------------------ include/linux/mtd/spi-nor.h | 2 +- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 4a513ed13807..2f79923e7db5 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1938,16 +1938,15 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) } /** - * macronix_quad_enable() - set QE bit in Status Register. + * spi_nor_sr1_bit6_quad_enable() - Set the Quad Enable BIT(6) in the Status + * Register 1. * @nor: pointer to a 'struct spi_nor' * - * Set the Quad Enable (QE) bit in the Status Register. - * - * bit 6 of the Status Register is the QE bit for Macronix like QSPI memories. + * Bit 6 of the Status Register 1 is the QE bit for Macronix like QSPI memories. * * Return: 0 on success, -errno otherwise. */ -static int macronix_quad_enable(struct spi_nor *nor) +static int spi_nor_sr1_bit6_quad_enable(struct spi_nor *nor) { int ret; @@ -1955,25 +1954,12 @@ static int macronix_quad_enable(struct spi_nor *nor) if (ret) return ret; - if (nor->bouncebuf[0] & SR_QUAD_EN_MX) + if (nor->bouncebuf[0] & SR1_QUAD_EN_BIT6) return 0; - nor->bouncebuf[0] |= SR_QUAD_EN_MX; + nor->bouncebuf[0] |= SR1_QUAD_EN_BIT6; - ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); - if (ret) - return ret; - - ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); - if (ret) - return ret; - - if (!(nor->bouncebuf[0] & SR_QUAD_EN_MX)) { - dev_err(nor->dev, "Macronix Quad bit not set\n"); - return -EIO; - } - - return 0; + return spi_nor_write_sr1_and_check(nor, nor->bouncebuf[0], 0xFF); } /** @@ -2277,7 +2263,7 @@ static void gd25q256_default_init(struct spi_nor *nor) * indicate the quad_enable method for this case, we need * to set it in the default_init fixup hook. */ - nor->flash.quad_enable = macronix_quad_enable; + nor->flash.quad_enable = spi_nor_sr1_bit6_quad_enable; } static struct spi_nor_fixups gd25q256_fixups = { @@ -3661,7 +3647,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, case BFPT_DWORD15_QER_SR1_BIT6: nor->flags &= ~SNOR_F_HAS_16BIT_SR; - flash->quad_enable = macronix_quad_enable; + flash->quad_enable = spi_nor_sr1_bit6_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT7: @@ -4558,7 +4544,7 @@ static int spi_nor_setup(struct spi_nor *nor, static void macronix_set_default_init(struct spi_nor *nor) { - nor->flash.quad_enable = macronix_quad_enable; + nor->flash.quad_enable = spi_nor_sr1_bit6_quad_enable; nor->flash.set_4byte = macronix_set_4byte; } diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index fc3a8f5209f0..3a835de90b6a 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -133,7 +133,7 @@ #define SR_E_ERR BIT(5) #define SR_P_ERR BIT(6) -#define SR_QUAD_EN_MX BIT(6) /* Macronix Quad I/O */ +#define SR1_QUAD_EN_BIT6 BIT(6) /* Enhanced Volatile Configuration Register bits */ #define EVCR_QUAD_EN_MICRON BIT(7) /* Micron Quad I/O */ From patchwork Tue Sep 17 15:55:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149115 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57B6414F7 for ; Tue, 17 Sep 2019 16:08:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C0F9214AF for ; Tue, 17 Sep 2019 16:08:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nOmF0emC"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="uUUy02hl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C0F9214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=5jn9Fyg2PHg8yKlVTl19Ua1tc8gTKsktHIlbLauWk8g=; b=nOmF0emCdK3Bd+ zYp5JAmh82zYZlvgIow+bjE76A7KndJPhods5ygNDhksW5/rLPyHo0Kw7cxE907XuN3LZO1Z6wsaa PRJTUsT9f9R0fC2qBi/3iXc+nIE5xbHZocZD8QKIzoL238gB5Lu/pxBViq4P5jBP4sxcXtD7prb2Z qoTUDyxZacPbMc1CQYDvBS0QQEhlY+7m3/Ajmz+xIOwmYF2tS/Ch45DTwwSV5cZ+bKJc2cGMp2PMW Lgmwzmd0axbUMxd0VKyrG9Q1zclC5tL6OdqdbwhedMWM5EBpeFwTC7Dc7vO4BzMzo2x/niHAcbdja cPDTM/tb8ItgeAV/jYAw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG2C-0004l6-JY; Tue, 17 Sep 2019 16:08:56 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpW-00086p-Rh; Tue, 17 Sep 2019 15:55:52 +0000 Received-SPF: Pass (esa4.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa4.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa4.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: ulW1nNB2g9NH+uWDigwRfTkxQSKPa832uv9RIf9rUwdnTvHbqPWbcaicuiizn5EpHxwksuF1Dr 53418hG/zruYESWM8Um+9WUGgZh2X5OpWY5LI2iSyYnmZ3aAOlq477QKBypP2+0oVSqQpnTYMF 15AaLWBAot0Ieb8/8n6Z8DEK2Cak26+QVOpiYuuKu3IWyhu4/4aJCZMp2CBdao+xi6nFGdWofT Y38C2w5fYfdVxr3tagKLmIeXgCBF+KkLo6YN8WVYHyUU2LpZnDZgquOhriaYmEcmyAKUluzOo4 PCk= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="48252515" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:47 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:44 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YhdEnWa+Tzgb0QwK4kATS4c2neXQWHNTkBCZ+5Aa8WOVNAun/T2pQBUkbycaj8mcc6gWa9aNkkfDTsSHlV611oqxkKltXFL3/01K4471Ftn2K9BpMuurEsdQdoXvlnNkZRnykQYXtKuGxTxVpKsuDRPRUQ9pcrOxl8L7gp0Ji+ed5liFWF4xvN848//QjhfkaEAOgBIuVpeRXNU9W80YxN+z+jOVQ3OjAFOQ62s54lfpUTR2jBK2+aFMZte5+xMHpOnd5S+RZZzWCQuhfUqMEkWxuPKF5mhD08nFmhQYb8DoADzixSS/h3A61Df/6kD68UZHkAfe6RKvh7C3Q15Aqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5ecCpdDpENn6qqT8qOX1kBqG9SvcVtPQmFAkNLaJlDA=; b=a1fC0TpT9xEF61papq3xQqiK7sxw3QWx5g0OlkCpy+ZnkGNCjUmmndlFx+QG8GobRRwGR6/Z4XlsTcDe5Ifs++gfZQH+Z8e0gzVpGBk0/g/j2HsWbHTyRY6rrQ6xOVLvHKaknx70SvvJYZ9t3owPGDmGaHk/yvrXsliWtHbFYRxajT5owUqpu6PksScGpd15RECfhVI4xtg1y2YHF7DZowwdm+kIK9KkJqbQz2x4SQTgpUIw14lD+N661szT2PHUWAgx6TGFbgy7MsO7gz8DUMfC+FaUDZq4MfmJuXYF4na4u3xH5dnqCWXNx+5xKvkR7irmoZadQctD8w69x6fGIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5ecCpdDpENn6qqT8qOX1kBqG9SvcVtPQmFAkNLaJlDA=; b=uUUy02hls+4NJglbSP4ikoCS1x3qNxf03A2eFLASylKKa2ckTg0taL7xnUVSMC2wvN7AJllqGFC7rSQtyn/iOtQiwFfeU5XwepH4nzs9QvUnuGqQ/7Yj4ULBk7JOZHkXg94TsGX7z8jTDvM0n/5LQUNBx1w3APXmmG8QgP1lRlQ= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:42 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:42 +0000 From: To: , , , , , Subject: [PATCH 19/23] mtd: spi-nor: Rework spansion(_no)_read_cr_quad_enable() Thread-Topic: [PATCH 19/23] mtd: spi-nor: Rework spansion(_no)_read_cr_quad_enable() Thread-Index: AQHVbXBbffKexv8yJ0aKaPhVIe5Rwg== Date: Tue, 17 Sep 2019 15:55:41 +0000 Message-ID: <20190917155426.7432-20-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2cf3481b-77d1-4729-96e7-08d73b877dfb x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: K3waqPD9N9/+H6ea/bhvuFkXNJl3RxrTcMGqxyw2OcKSmN9u20xe70/cYoDoR9xQJJzYuMP6TSYVyrWruJHPSuI4loWvIla9zV3PDdHIbKKckHylPk1JFWqr5LFF4rkhylVRaa/uNgY0FHiSOQ+gZhC4ayHuX0O2hrDha1YmFjKZU60l0+OZ1QjQ8FP0a6vcrGNHRb11fPvSwc0cwvYGhYlp9WlTCCvVAuCEknCXV/WVpMTU4xFufxsdLomkgxPedmNhk1Wu4ZAgDqr9Gr2SZ9I7sKOABQnShhvu9Kkvltoa/dfR7dwbDEL7pYQ+/pKl/Sm/YS3e0r+ygh1atERvHBJmKZv0+hDRmsx3YNvevbKBTs3K9Tie3mkNfS42S0H7KK2dx8Tt1DVvk9NbSuUXiJAxEQDfK9ec8AE1rXW+l8A= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2cf3481b-77d1-4729-96e7-08d73b877dfb X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:41.9986 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: r/Jfp3/Hty199zVI/uObHy4ydUkd78Y1IFGYNZLl9r9pszP8r51pYVwb4n1+anxP2DfmZhknV3I//mWEmI7Q3xmz51oUFWjvULNp44jaZwI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085551_007050_EDFB9CE5 X-CRM114-Status: GOOD ( 15.47 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.154.123 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Merge: spansion_no_read_cr_quad_enable() spansion_read_cr_quad_enable() in spi_nor_sr2_bit1_quad_enable(). Avoid duplication of code by using spi_nor_write_16bit_sr_and_check(), the SNOR_F_NO_READ_CR case is treated there. We now do the Read Back test even for the old spansion_no_read_cr_quad_enable() case. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 89 ++++++++++--------------------------------- include/linux/mtd/spi-nor.h | 4 +- 2 files changed, 22 insertions(+), 71 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 2f79923e7db5..8648666fb9bd 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -907,7 +907,7 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 status_new, * Write Status (01h) command is available just for the cases * in which the QE bit is described in SR2 at BIT(1). */ - sr_cr[1] = CR_QUAD_EN_SPAN; + sr_cr[1] = SR2_QUAD_EN_BIT1; } else { sr_cr[1] = 0; } @@ -1963,81 +1963,34 @@ static int spi_nor_sr1_bit6_quad_enable(struct spi_nor *nor) } /** - * spansion_no_read_cr_quad_enable() - set QE bit in Configuration Register. + * spi_nor_sr2_bit1_quad_enable() - set the Quad Enable BIT(1) in the Status + * Register 2. * @nor: pointer to a 'struct spi_nor' * - * Set the Quad Enable (QE) bit in the Configuration Register. - * This function should be used with QSPI memories not supporting the Read - * Configuration Register (35h) instruction. - * - * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI - * memories. - * - * Return: 0 on success, -errno otherwise. - */ -static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) -{ - u8 *sr_cr = nor->bouncebuf; - int ret; - - /* Keep the current value of the Status Register. */ - ret = spi_nor_read_sr(nor, &sr_cr[0]); - if (ret) - return ret; - - sr_cr[1] = CR_QUAD_EN_SPAN; - - return spi_nor_write_sr(nor, sr_cr, 2); -} - -/** - * spansion_read_cr_quad_enable() - set QE bit in Configuration Register. - * @nor: pointer to a 'struct spi_nor' - * - * Set the Quad Enable (QE) bit in the Configuration Register. - * This function should be used with QSPI memories supporting the Read - * Configuration Register (35h) instruction. - * - * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI - * memories. + * Bit 1 of the Status Register 2 is the QE bit for Spansion like QSPI memories. * * Return: 0 on success, -errno otherwise. */ -static int spansion_read_cr_quad_enable(struct spi_nor *nor) +static int spi_nor_sr2_bit1_quad_enable(struct spi_nor *nor) { - u8 *sr_cr = nor->bouncebuf; int ret; - /* Check current Quad Enable bit value. */ - ret = spi_nor_read_cr(nor, &sr_cr[1]); - if (ret) - return ret; - - if (sr_cr[1] & CR_QUAD_EN_SPAN) - return 0; + if (!(nor->flags & SNOR_F_NO_READ_CR)) { + /* Check current Quad Enable bit value. */ + ret = spi_nor_read_cr(nor, &nor->bouncebuf[0]); + if (ret) + return ret; - sr_cr[1] |= CR_QUAD_EN_SPAN; + if (nor->bouncebuf[0] & SR2_QUAD_EN_BIT1) + return 0; + } /* Keep the current value of the Status Register. */ - ret = spi_nor_read_sr(nor, &sr_cr[0]); - if (ret) - return ret; - - ret = spi_nor_write_sr(nor, sr_cr, 2); - if (ret) - return ret; - - /* Read back and check it. */ - ret = spi_nor_read_cr(nor, &sr_cr[1]); + ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); if (ret) return ret; - if (!(sr_cr[1] & CR_QUAD_EN_SPAN)) { - dev_err(nor->dev, "Spansion Quad bit not set\n"); - return -EIO; - } - - return 0; + return spi_nor_write_16bit_sr_and_check(nor, nor->bouncebuf[0], 0xFF); } /** @@ -2117,7 +2070,7 @@ static int spi_nor_clear_sr_bp(struct spi_nor *nor) * * Read-modify-write function that clears the Block Protection bits from the * Status Register without affecting other bits. The function is tightly - * coupled with the spansion_read_cr_quad_enable() function. Both assume that + * coupled with the spi_nor_sr2_bit1_quad_enable() function. Both assume that * the Write Register with 16 bits, together with the Read Configuration * Register (35h) instructions are supported. * @@ -2138,7 +2091,7 @@ static int spi_nor_spansion_clear_sr_bp(struct spi_nor *nor) * When the configuration register Quad Enable bit is one, only the * Write Status (01h) command with two data bytes may be used. */ - if (sr_cr[1] & CR_QUAD_EN_SPAN) { + if (sr_cr[1] & SR2_QUAD_EN_BIT1) { ret = spi_nor_read_sr(nor, &sr_cr[0]); if (ret) return ret; @@ -3642,7 +3595,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, * supported. */ nor->flags |= SNOR_F_NO_READ_CR; - flash->quad_enable = spansion_no_read_cr_quad_enable; + flash->quad_enable = spi_nor_sr2_bit1_quad_enable; break; case BFPT_DWORD15_QER_SR1_BIT6: @@ -3663,7 +3616,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, * assumption of a 16-bit Write Status (01h) command. */ nor->flags |= SNOR_F_HAS_16BIT_SR; - flash->quad_enable = spansion_read_cr_quad_enable; + flash->quad_enable = spi_nor_sr2_bit1_quad_enable; break; default: @@ -4626,7 +4579,7 @@ static void spi_nor_info_init_flash_params(struct spi_nor *nor) u8 i, erase_mask; /* Initialize legacy flash parameters and settings. */ - flash->quad_enable = spansion_read_cr_quad_enable; + flash->quad_enable = spi_nor_sr2_bit1_quad_enable; flash->set_4byte = spansion_set_4byte; flash->setup = spi_nor_default_setup; /* Default to 16-bit Write Status (01h) Command */ @@ -4844,7 +4797,7 @@ static int spi_nor_init(struct spi_nor *nor) int err; if (nor->clear_sr_bp) { - if (nor->flash.quad_enable == spansion_read_cr_quad_enable) + if (nor->flash.quad_enable == spi_nor_sr2_bit1_quad_enable) nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp; err = nor->clear_sr_bp(nor); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 3a835de90b6a..5590a36eb43e 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -144,10 +144,8 @@ #define FSR_P_ERR BIT(4) /* Program operation status */ #define FSR_PT_ERR BIT(1) /* Protection error bit */ -/* Configuration Register bits. */ -#define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ - /* Status Register 2 bits. */ +#define SR2_QUAD_EN_BIT1 BIT(1) #define SR2_QUAD_EN_BIT7 BIT(7) /* Supported SPI protocols */ From patchwork Tue Sep 17 15:55:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 096DD14F7 for ; Tue, 17 Sep 2019 16:08:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DAC38214AF for ; Tue, 17 Sep 2019 16:08:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eIXKM/Ht"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="HLq1VxZb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DAC38214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=x/fjd1qqkoFbLpOu+2eIVb6dWLxdKikAMV7Qhkq66uo=; b=eIXKM/Hte6JKZu 1aGebwDMT3fNktscCWLmVuwsfd/IlGy4E6pHNZtq2RJq5bo5ocoIupw9QbfRQ30A3Ix776EyvPfDw ArSxB1Ap249P4UxHw4uziOxKaKmBluy0zIt19b7S71nowX+Misz6j38P6Szuv2b0aFQVSTvHpR09w kMPkQZD5O07BNRXp+JO54TEGNHXBXDWFt+K13dL+jDOdqiSctuhHeeNh/c3aCphJ92AaLSyL87WDt mOELmvAgwA6VvDvKraQ1F0UrFZfMLijijvsHUviXgAMwI3H2oV8VVkB5C9mMRf1nvUoyXff/k+iXm 3uEHeXe0efyR0Ae69Wgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG1H-0003k0-CQ; Tue, 17 Sep 2019 16:07:59 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpU-00086y-9f; Tue, 17 Sep 2019 15:55:50 +0000 Received-SPF: Pass (esa2.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa2.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa2.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: Va9BnOOGfjfaYo5P3ii0iU0a8hRfhcCz6worcyGpFqDWWAKaHeiqOzeWAraEfIv6DrlG5tsnZG VwIxklI/5nmBXrcJ6qnnbrfe3pJK7SoHeGuiSUwn36Sn2Kjev9xGEm+SbhToKFbh0/5i/4sAJ4 vy4zrAnH3RckkLivR1m1U39ZiE3GOW65fVa7RhiGw13ODwQkJszaApBevMCI5pNakrH4J+WjXO x6brGQrkN9l4U1gi/GeL5oJPk3FOSD4mX8IiI6+zfh4UrI/lTJS+KKRjDIme+uBqsi7QR0BMBm Zm4= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="49243092" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:46 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:46 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EadyAmk6LBZMdqkW/tAEHUAbimU6gPBJllFgzS11u5Hm0Z3WWJPa/XtC1OfABiDTe24QDDEM+3gcMu4gTgk7TvHTgaeu7IGeyrvyjRiT9CExosSQsikGUw2TDuszR1jN244WCIdOPmg3CVTUTxUX5nLpOWNllBeUPugqcV+vLK2pRSNv2XFfUwL+1df8tOiKFmpJTQfEY6kqXrKFA9zh0He9u5tVDG3gNyJgh4Q899TJWVpmC356xNDoK8EnNU0ABbdymKjVMKXUphYoxsLFbi2BJVSSTdK1iRn8zRZ4I6cAwfqYPukBrwFZUMRASq+U4gVHthFLcbWxpmGJQuQpbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M8ZMyk+kYEAol0HDDHE66QDG60dnjfVgAyQ9mr3qM0I=; b=CMI3rGJjNRHITBOpC5xMVgx/FxNaLwLZzbyxVSYY81XznSHaFyMwoSO53t4KIchVzExzwdvzIF2Iec6T2yjzUr3PmizPn/rDn9ansk7lCP7qxtSGAWvideWp9K1qTLiLhUUbvK93sx5L5HQ6DZ5J5l18vuL1d0gfJamXjIyzy+XYsAD/749gMj1c2YC//qi8SWXPHPJsKidkY18sItLrIJSQCQTjVQT7qP30/tTBehON3rMEsiBKHgB05MSAm0oKzeVnYFnxrKRsCBomYlLa3uw7M0UV0mYg6AahX7JxMD1UICun/stcg5XDZ6qfIbZbz/EZGPuiG1qz25TuOF2b7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M8ZMyk+kYEAol0HDDHE66QDG60dnjfVgAyQ9mr3qM0I=; b=HLq1VxZbKe7AcpsyENB/06EIYwKwl4CgW56OIYTOu0EzEUeuFPhBZjkLM/Y3SgjNswj01ZoTBDucBLMeLT4HeTE9x3SgDuh4x8tsWbo0654vYOflzZvimkpzFGhXs7UQuGpGASkkIT16Byfr06zjJprdXVkOdB5qtywSteDhSkg= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:45 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:45 +0000 From: To: , , , , , Subject: [PATCH 20/23] mtd: spi-nor: Update sr2_bit7_quad_enable() Thread-Topic: [PATCH 20/23] mtd: spi-nor: Update sr2_bit7_quad_enable() Thread-Index: AQHVbXBdQKqFCEhfJk6GjF8offODhQ== Date: Tue, 17 Sep 2019 15:55:45 +0000 Message-ID: <20190917155426.7432-21-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4ad8ddeb-bd52-4c24-e894-08d73b877fe1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jAofMaD55D6ZXcEJtTQVrREo2F3jJcTJYt+hHAZUGXGyJFT7VCr+tTwX9X1yeQzpN/uf+5PCc2uSNJNTcOVGNshsZVGvLY8vxSV3e80zTu57MAaJnYC88DQP++02PRgeWxasMV4R+bXV8k+19rXYGFSPpK6XMZaYbCrrh9xrveMvcUcc5z4Qu5BYV7iunKM6TumO8lmitH7AbRK7E2M7KY9N3OvqeKadvRSgvcwohtughJGbGeM8il4cD7M+Ei3tSPoPYNY115esvsqf2284s1DVDFwGGnzRAeb5BhFT6j8ZSTf0aajSBTelnfEhN+D5z2ve/0cvpnL6fpLLsEVQS20o7LuiT+TRhXsswbem2C32H6k741RkT2QNT/PHfeULCGaHr9OUSzA7kggt0igiQGjXkRkEoMT5RU3ZV8SDqsE= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 4ad8ddeb-bd52-4c24-e894-08d73b877fe1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:45.1458 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: RKSnW3rzr6dbPTQPL8TjCcw2dNo1i6OLXd7VItTfrZmLCBuFkpXatsoG9pNXgL1PMU8HJY5mG04P5c19/SendsaghdkpkOp+cj50fcdgcLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085549_265533_58DC98A3 X-CRM114-Status: UNSURE ( 9.71 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.149.84 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Rename the method to spi_nor_sr2_bit7_quad_enable(). Do the read back test on all the eight bits of the Status Register, not just the QE one. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 8648666fb9bd..a9cdb6dbc25c 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1994,7 +1994,7 @@ static int spi_nor_sr2_bit1_quad_enable(struct spi_nor *nor) } /** - * sr2_bit7_quad_enable() - set QE bit in Status Register 2. + * spi_nor_sr2_bit7_quad_enable() - set QE bit in Status Register 2. * @nor: pointer to a 'struct spi_nor' * * Set the Quad Enable (QE) bit in the Status Register 2. @@ -2005,10 +2005,11 @@ static int spi_nor_sr2_bit1_quad_enable(struct spi_nor *nor) * * Return: 0 on success, -errno otherwise. */ -static int sr2_bit7_quad_enable(struct spi_nor *nor) +static int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor) { u8 *sr2 = nor->bouncebuf; int ret; + u8 sr2_written; /* Check current Quad Enable bit value. */ ret = spi_nor_read_sr2(nor, sr2); @@ -2025,13 +2026,15 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) if (ret) return ret; + sr2_written = *sr2; + /* Read back and check it. */ ret = spi_nor_read_sr2(nor, sr2); if (ret) return ret; - if (!(*sr2 & SR2_QUAD_EN_BIT7)) { - dev_err(nor->dev, "SR2 Quad bit not set\n"); + if (*sr2 != sr2_written) { + dev_err(nor->dev, "Read back test failed\n"); return -EIO; } @@ -3605,7 +3608,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, case BFPT_DWORD15_QER_SR2_BIT7: nor->flags &= ~SNOR_F_HAS_16BIT_SR; - flash->quad_enable = sr2_bit7_quad_enable; + flash->quad_enable = spi_nor_sr2_bit7_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT1: From patchwork Tue Sep 17 15:55:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF17D1747 for ; Tue, 17 Sep 2019 16:10:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C48BC206C2 for ; Tue, 17 Sep 2019 16:10:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Eka1PyT/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="aAYI6xPP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C48BC206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=TCna8iu+Y0zBFmz9+u1aaItGCGKI+/EDFN1NCiuDy0o=; b=Eka1PyT/aBd9CZ ogwgnpwZwQekiVr05tTMobcbh7RDgrHehBZnAHMyLtK9WyLfPVNGbOAqZN0Chp17DUOsD5hbubEvk iQwly0wF1ovdJ9NEYjehUVztYnD0xLkS8h9ta7AVhsb6YDC+k59YMfGjWuJIY6nFdeKzcCWRZnJA0 sXOHZvhru3uK/qkAPEq46R0IYpu/LxAlwIC+HvJF3mAaEW/iXn4gbR6FqHJPZ+ivCjF5I4ds2Pf0J lCnLcugQd6iRNuwRO5idlw2szd5dr9H8gWH09TLtof+AlJh3boPF0auTQix7f6+WM9zlMOGsQ2ZGF NeylF2yCQ35elmkv6nig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG3H-0005oW-4g; Tue, 17 Sep 2019 16:10:03 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpb-00086p-L5; Tue, 17 Sep 2019 15:55:58 +0000 Received-SPF: Pass (esa4.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa4.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa4.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: Apf1B9GJCiZDw+jQA31CcWj4oz26+t/0yIeReSUuM2R2wMhjHYi1J9pdTuTWAmAsjzM00P1lqG ZiQc5vnDQtG5QazFYZz/Jjb5IO6LuV4ck42EUq4LwGRK4wBf1z3/pfa9C0JYY6TTafppIl+LiV hrioTakKWdcSZr2idnYhGGpj7fnmrEftluHlGSZTTrCeMhh0W8ReohdxCjsaXOxdd1JTtD8cal StB0n47SUtlefexD5YOjEW3yh52fZ9NKNaazSY0m7y57QOW4leO7Mq4PxHCxG6Jg2ysYYDB/ju 8C8= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="48252547" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:51 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:50 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E8JbjJl5zACw/hJt+IO7AQJF7DwgD0/MmCruhfNDM08k+w2dBJI5GDwmEavMyHdorQwTdXEe7A/C5u4jkHMY4KBKL5W2bl/1irgJQpWHyKvIdLygGa2Qj+EVx48yO+nO4CxFly7LbyjlCVtAzD22QJLmzPA3kH0u/DPMXcUbLOPQwY6gUneoXg1837YMhmJLexF15Axw6V0PJp8ZGQ4mRhzzL+jecWRdvrEa0S4yoJf3UrP+OZK+zzj9FjIBotTr4VRjLPGgMOb6IlwwTykwLTLbO9gG8qxH2ztHxpSr1cGpeDKLlmdgx7OMNvqDPGznmq3h+81Nok8Q8s4vcmzXUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oYQcNrzAE6sZu8knUk88f5RkdGT4W8F0yTAM/RLgr64=; b=PB4AFlzdxcS4etnf3E85UHoHOpN4n1atr0VBR0hswZaPX56auBin8Cg47GONykv1Ehgy9XnSZi6nH/CCjDzwY6DqgGRooNO9qod6ik+YOaVabMQn0A+6hPiMNwMIowSJ9byP5D8kPFSXIz+Gu3IlEx0QEO35G6giQcy7JeoOa04PDfvWIlodHgd+o6B5j6QFu3VzTnDk1r9KUyn2/2AzpeZYqQzOW143q+S1Yqf6M5noj0pSoAdXpqFjzXO06gfUCdGPphRJ8gInBoRNCt0Pl2SEvM9UlscxOzMOQSJEKkDQbE0ar+X6zkHLzq8xGWaskho1on8Lkz7cs0pFsv+w9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oYQcNrzAE6sZu8knUk88f5RkdGT4W8F0yTAM/RLgr64=; b=aAYI6xPPsisV/+a1CXvzQPineF0ISd4FzPct8TrCMQxhfkC3NOXRbxBGUhdId8eRarQyNNU1zDDiPN0ljyQ/+R/mQGbLPl7TCTDpeLZQTRm81kWDLlTvoX0eut/egQ9Y5O9enBPfctonmyCxapXFY/nFarbUNfSPbvWFM1tindQ= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:48 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:48 +0000 From: To: , , , , , Subject: [PATCH 21/23] mtd: spi-nor: Rework the disabling of block write protection Thread-Topic: [PATCH 21/23] mtd: spi-nor: Rework the disabling of block write protection Thread-Index: AQHVbXBftJMrp6jhCUKqN9qjMF7NVA== Date: Tue, 17 Sep 2019 15:55:48 +0000 Message-ID: <20190917155426.7432-22-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fab42252-9c6d-45d0-8853-08d73b8781c8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(14444005)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: BGjqiiaH8L5zq8jYmTJ58eIaSv4m4g1wNav9T3B4eN97IdkoHAy8DQfOjBH5OywIZii+8dtsbMlDO084xF66piy/Hj5S+HgVIJzOf5E1GdYXCx5fVr/JrUTxBq9+fDqpn/cycSKufJ3IMdfuQM/Rfl2Nyl+HDyuSx2lJnm4oCxfueTTOf9pEX0h/qluoeXa26JCpjdBPOkaZ00PsapbtsQBihWslrrzN41vFZnn2egAZm2xasGsNm1DumwwOAHmQ1pj3imKH63V4/5/pE5JZDHaD4PyPygNyzMIEYHO/nyaTWL6GlvLLLGby0nD9XrcvJXTsVKeaf4dXpI5MRQdoXeqs7usc0YJe5Dksp1kweTyio3yrzJ/Y9PLdTwrNIj/Wi+JRgtN43o05oxD/83zW2UVycLCW6H0ze4MRz8hgP4M= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: fab42252-9c6d-45d0-8853-08d73b8781c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:48.3239 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JJDxHIyNi2cQHtrfufxc5nOzD2TKf+K4CSgQYQxZoNUHQ2wEUEmhoA8fWKHZRnHhLKGP9orkJoEZNKwKgZxhQn4x+V+xjifdO6KK52rEX4k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085556_104407_38CC3499 X-CRM114-Status: GOOD ( 19.69 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.154.123 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus spi_nor_unlock() unlocks blocks of memory or the entire flash memory array, if requested. clear_sr_bp() unlocks the entire flash memory array at boot time. This calls for some unification, clear_sr_bp() is just an optimization for the case when the unlock request covers the entire flash size. Get rid of clear_sr_bp() and introduce spi_nor_unlock_all(), which is just a call to spi_nor_unlock() for the entire flash memory array. This fixes a bug that was present in spi_nor_spansion_clear_sr_bp(). When the QE bit was zero, we used the Write Status (01h) command with one data byte, which might cleared the Status Register 2. We now always use the Write Status (01h) command with two data bytes when SNOR_F_HAS_16BIT_SR is set, to avoid clearing the Status Register 2. Get rid of the MFR handling and implement specific manufacturer default_init() fixup hooks. Note that this changes a bit the logic for the SNOR_MFR_ATMEL, SNOR_MFR_INTEL and SNOR_MFR_SST cases. Before this patch, the Atmel, Intel and SST chips did not set the locking ops, but unlocked the entire flash at boot time, while now they are setting the locking ops to stm_locking_ops. This should work, since the the disable of the block protection at the boot time used the same Status Register bits to unlock the flash, as in the stm_locking_ops case. Suggested-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 142 +++++++++++++++--------------------------- include/linux/mtd/spi-nor.h | 3 - 2 files changed, 49 insertions(+), 96 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index a9cdb6dbc25c..700b1700a7a1 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2041,79 +2041,6 @@ static int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor) return 0; } -/** - * spi_nor_clear_sr_bp() - clear the Status Register Block Protection bits. - * @nor: pointer to a 'struct spi_nor' - * - * Read-modify-write function that clears the Block Protection bits from the - * Status Register without affecting other bits. - * - * Return: 0 on success, -errno otherwise. - */ -static int spi_nor_clear_sr_bp(struct spi_nor *nor) -{ - int ret; - u8 mask = SR_BP2 | SR_BP1 | SR_BP0; - - ret = spi_nor_read_sr(nor, &nor->bouncebuf[0]); - if (ret) - return ret; - - nor->bouncebuf[0] &= mask; - - ret = spi_nor_write_sr(nor, &nor->bouncebuf[0], 1); - - return ret; -} - -/** - * spi_nor_spansion_clear_sr_bp() - clear the Status Register Block Protection - * bits on spansion flashes. - * @nor: pointer to a 'struct spi_nor' - * - * Read-modify-write function that clears the Block Protection bits from the - * Status Register without affecting other bits. The function is tightly - * coupled with the spi_nor_sr2_bit1_quad_enable() function. Both assume that - * the Write Register with 16 bits, together with the Read Configuration - * Register (35h) instructions are supported. - * - * Return: 0 on success, -errno otherwise. - */ -static int spi_nor_spansion_clear_sr_bp(struct spi_nor *nor) -{ - int ret; - u8 mask = SR_BP2 | SR_BP1 | SR_BP0; - u8 *sr_cr = nor->bouncebuf; - - /* Check current Quad Enable bit value. */ - ret = spi_nor_read_cr(nor, &sr_cr[1]); - if (ret) - return ret; - - /* - * When the configuration register Quad Enable bit is one, only the - * Write Status (01h) command with two data bytes may be used. - */ - if (sr_cr[1] & SR2_QUAD_EN_BIT1) { - ret = spi_nor_read_sr(nor, &sr_cr[0]); - if (ret) - return ret; - - sr_cr[0] &= ~mask; - - ret = spi_nor_write_sr(nor, sr_cr, 2); - if (ret) - dev_err(nor->dev, "16-bit write register failed\n"); - return ret; - } - - /* - * If the Quad Enable bit is zero, use the Write Status (01h) command - * with one data byte. - */ - return spi_nor_clear_sr_bp(nor); -} - /* Used when the "_ext_id" is two bytes at most */ #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \ .id = { \ @@ -4498,6 +4425,16 @@ static int spi_nor_setup(struct spi_nor *nor, return nor->flash.setup(nor, hwcaps); } +static void atmel_set_default_init(struct spi_nor *nor) +{ + nor->flags |= SNOR_F_HAS_LOCK; +} + +static void intel_set_default_init(struct spi_nor *nor) +{ + nor->flags |= SNOR_F_HAS_LOCK; +} + static void macronix_set_default_init(struct spi_nor *nor) { nor->flash.quad_enable = spi_nor_sr1_bit6_quad_enable; @@ -4511,6 +4448,11 @@ static void st_micron_set_default_init(struct spi_nor *nor) nor->flash.set_4byte = st_micron_set_4byte; } +static void sst_set_default_init(struct spi_nor *nor) +{ + nor->flags |= SNOR_F_HAS_LOCK; +} + static void winbond_set_default_init(struct spi_nor *nor) { nor->flash.set_4byte = winbond_set_4byte; @@ -4525,6 +4467,14 @@ static void spi_nor_manufacturer_init_flash_params(struct spi_nor *nor) { /* Init flash parameters based on MFR */ switch (JEDEC_MFR(nor->info)) { + case SNOR_MFR_ATMEL: + atmel_set_default_init(nor); + break; + + case SNOR_MFR_INTEL: + intel_set_default_init(nor); + break; + case SNOR_MFR_MACRONIX: macronix_set_default_init(nor); break; @@ -4534,6 +4484,10 @@ static void spi_nor_manufacturer_init_flash_params(struct spi_nor *nor) st_micron_set_default_init(nor); break; + case SNOR_MFR_SST: + sst_set_default_init(nor); + break; + case SNOR_MFR_WINBOND: winbond_set_default_init(nor); break; @@ -4795,20 +4749,32 @@ static int spi_nor_quad_enable(struct spi_nor *nor) return nor->flash.quad_enable(nor); } +/** + * spi_nor_unlock_all() - Unlocks the entire flash memory array. + * @nor: pointer to a 'struct spi_nor' + * + * Some SPI NOR flashes are write protected by default after a power-on reset + * cycle, in order to avoid inadvertent writes during power-up. Backward + * compatibility imposes to unlock the entire flash memory array at power-up + * by default. + */ +static int spi_nor_unlock_all(struct spi_nor *nor) +{ + if (nor->flags & SNOR_F_HAS_LOCK) + return spi_nor_unlock(&nor->mtd, 0, nor->flash.size); + + return 0; +} + static int spi_nor_init(struct spi_nor *nor) { int err; - if (nor->clear_sr_bp) { - if (nor->flash.quad_enable == spi_nor_sr2_bit1_quad_enable) - nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp; - - err = nor->clear_sr_bp(nor); - if (err) { - dev_err(nor->dev, - "fail to clear block protection bits\n"); - return err; - } + err = spi_nor_unlock_all(nor); + if (err) { + dev_err(nor->dev, + "Failed to unlock the entire flash memory array\n"); + return err; } err = spi_nor_quad_enable(nor); @@ -4999,16 +4965,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, if (info->flags & SPI_NOR_HAS_LOCK) nor->flags |= SNOR_F_HAS_LOCK; - /* - * Atmel, SST, Intel/Numonyx, and others serial NOR tend to power up - * with the software protection bits set. - */ - if (JEDEC_MFR(nor->info) == SNOR_MFR_ATMEL || - JEDEC_MFR(nor->info) == SNOR_MFR_INTEL || - JEDEC_MFR(nor->info) == SNOR_MFR_SST || - nor->info->flags & SPI_NOR_HAS_LOCK) - nor->clear_sr_bp = spi_nor_clear_sr_bp; - /* Init flash parameters based on flash_info struct and SFDP */ spi_nor_init_flash_params(nor); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 5590a36eb43e..ca650f895903 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -578,8 +578,6 @@ struct flash_info; * @write_proto: the SPI protocol for write operations * @reg_proto the SPI protocol for read_reg/write_reg/erase operations * @controller_ops: SPI NOR controller driver specific operations. - * @clear_sr_bp: [FLASH-SPECIFIC] clears the Block Protection Bits from - * the SPI NOR Status Register. * @flash: SPI-NOR flash parameters and settings. The structure * includes default flash parameters and settings that can * be overwritten by the spi_nor_fixups hooks, or @@ -608,7 +606,6 @@ struct spi_nor { const struct spi_nor_controller_ops *controller_ops; - int (*clear_sr_bp)(struct spi_nor *nor); struct spi_nor_flash_parameter flash; void *priv; From patchwork Tue Sep 17 15:55:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8712214DB for ; Tue, 17 Sep 2019 16:09:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6273C206C2 for ; Tue, 17 Sep 2019 16:09:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UyPUr9l8"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="A4NhEF9m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6273C206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=ZaCN8I9uDZ7/YywbmJ5gNczh6QQz45xLlUDk++HfzAw=; b=UyPUr9l84WiS78 37+VSdzcS5tjrn1kToyM49zthJR5UWh3AyHmKWyRmBGG04v8tAMFz57YRREJ69QHqaLp9dvuAIOjM VBg2FN8l/SliGWE9wgfBaWdsH78maneYHXQEIg2cEamMIUUt2DDbvtmwDtihy5sHdrswhYn8JZ8OW SlEftG0S62CtOUH1BxHLaOFV9pN+YfMy9Wz9gIL8PFp76/W36LRjYAC++vl0ubMvHun/BaRuvoXHf swNCriN29i48M/v22Pbpnu+88xHKcPjrfNkHE6odVaQfZeKwWu+/CKgdD3OgW0NVYJhap6gMpP3kX q/khxZMbaRGi4FG/zf+w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG2u-0005U9-2k; Tue, 17 Sep 2019 16:09:40 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpa-00086y-53; Tue, 17 Sep 2019 15:55:57 +0000 Received-SPF: Pass (esa2.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa2.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa2.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: C8weWO7QAE8r2/o7cx9v/YUxZMv8cBOafVxHdTEwFiF95GpN5G2kFHFRj3/hVFtBsaDR6wvnSp o9y7XHTaVD+bNVkJ96yCiuW3xBkDyEXnwUUn28qtsZkY2Vf5AqbCkjk97QUYuAIhomMsC9qbSo GZN4NI+OE89L1s/Vzn2SS0KblRa9AgZBGB2vxVnKdH4MzbCk0daYmLFQwXYTwKgg4Fy9d+ilkK PqPZGobEFy+rgakmI8vSglZaP2GvGoc76E3YrABYaXrYRtHepRMVTe1P9TDzy0FiTrTWRYGjVA JkI= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="49243122" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:53 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:53 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nah0AIHEO9L9VQsnIQhCsIxpumbu16AqRbM0/z0IY5j571S9i66QOOeSYOQ4q0l21caiy4XiGItOt3p2KNzFwexyaXKgIvRm29WBaeLOQGrS3qSaIPrHyUYDLgOwk/QGE5kibBy/lUJoee2FkBMD4xDCZLb6kcS/yk4MF0tgC3OJ4OvfRfYao1uoibNQS3pdl9rgCCFUsc21RRHeBjqp0fixwkwuOiMQGN7/OrNfQunw8R5Cxr9tJdmGwoj3bVzbhfOmNqTgziCI5DW6qOFLDKTr+wfvJTQtGXYuYfGSySTzEH1wnmiDRbb7DX02XvcMc8KAZBUhKnLWKpsfgi8GxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q6Eh5SflJdb49TE8n1mGrQv1pKZlZDu8sMpPAvbFwBw=; b=S5CALi/xTHeCNTtF9hIZTyuAlANLwbiwY+L7qxcr436BKa9jL705URsq9bxQM4uf0/1TCLYSqKhRygVX+sb87eVCBQIlH1HkHHtQcroG6KI/NEYTXZ85SoZ4lPSgEO5huK8aA04fjV0nQj6L2bcShGU1+Szc0ENVKm0IxFASr9iZQtzeMvVrjaXvffhbEQJGPzHliA4sdL90PCQlDBD+oG+x4VGZKYGKGRs+WDP4SlUqq8lSzsm/ldOXCZ8Ud9+/R42pG2M8C0ZrAzEdtt1gmfzstEptZWBoUDkI/wRx6wVngfKKiZXzGX9b7Wcc9+pm6PNRZFcxLe3Oy5RFCG+EPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q6Eh5SflJdb49TE8n1mGrQv1pKZlZDu8sMpPAvbFwBw=; b=A4NhEF9mnz+bMaJOVkn3VgxkJDsA+S/sRCO0pS7assg13+Q7qvqabOgK/78NJAE08hSlKxJsa1GNeQJ2gTg4m5Na9JdZZfJQQJ9q3CgMemJHipn8we3fMLrhKsDIPc3QOHy9t5TO6xUB2fTuiv3o1XvBgwfCO5xeUqPYyzm2NWc= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:51 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:51 +0000 From: To: , , , , , Subject: [PATCH 22/23] mtd: spi-nor: Add Global Block Unlock support Thread-Topic: [PATCH 22/23] mtd: spi-nor: Add Global Block Unlock support Thread-Index: AQHVbXBheu9K74Z1fkSibrgIdv0WJQ== Date: Tue, 17 Sep 2019 15:55:51 +0000 Message-ID: <20190917155426.7432-23-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2433c8dd-e160-42ff-658e-08d73b8783a5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(14444005)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: t+joOixquXLMtq4rYZKdSugIpKyaEhIPNsTBM+wsasrOqDpPBLgAuFyyiRxqzBBeo4JVdoG+NCsi8q6Zm3TKGQSCZQc6cVgW2GBTU5MDadKaeUgox8/kqp0obrON0IWEuONomk943kOJYUhydm8tr4v1a6XKY5f0j0OEZwylg/B1ywhwddwsydS8akxq6xxRKadROP5tE+pqks+L1GBsDgiKb04OgkZBTwIEmUH5JbIYufQxs9Wem451Ian0BTXNwXlQf9QAcgKhJodNmTap57DrXQcJFy72P48nzsqHdzvt8T8qCYY1J1TSBla6sJ2DWy7wjmEi2Bzia/J7Jbx1kH5jyxKWuaUhmMUdUvdNh+buvXgyxyGpGorsH9EEs7bAIHxjJIB9dK/ctLjXQH9E50ZI/1BWpMuOwtdL6y0+e6s= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2433c8dd-e160-42ff-658e-08d73b8783a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:51.4641 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rzyQAIFgw83cUJcYbCGbV7xdJaB3ULNjcw71Ycp8DYFmlOFlfcvDDD4BhXzQnrCA2TKS0HKtzd5ljZyLE/2+wFe6Nd6V8n9zAZGiH6xpmeA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085555_577953_988A54C1 X-CRM114-Status: GOOD ( 14.65 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.149.84 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus Add Global Block Unlock support as an optimization for unlocking the entire memory array. A Global Block-Protection Unlock command offers a single command cycle that unlocks the entire memory array. Status Register Block Protection support does not imply the support for the Global Block Unlock Command. Microchip's SST26VF064B does support the 98h command, but use dedicated registers for the individual block protection, and not the Status Register, as in the stm_lock/unlock case. Call spi_nor_unlock_global_block_protection() in spi_nor_unlock() as an optimization for unlocking the entire memory array. Note that the Global Block Unlock command has different names depending on the manufacturer, but always the same command value: 98h. Macronix's MX25U12835F names it Gang Block Unlock, Winbound's W25Q128FV names it Global Block Unlock and Microchip's SST26VF064B names it Global Block Protection Unlock. We can't determine this support purely by manufacturer type and it's not autodetectable by anything like SFDP, so make a new flag for it: UNLOCK_GLOBAL_BLOCK. This flag can be set just at per-chip level, we don't need a SNOR_F_ correspondent. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 47 +++++++++++++++++++++++++++++++++++++++++-- include/linux/mtd/spi-nor.h | 1 + 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 700b1700a7a1..19556a9dd3fa 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -196,7 +196,7 @@ struct flash_info { u16 page_size; u16 addr_width; - u16 flags; + u32 flags; #define SECT_4K BIT(0) /* SPINOR_OP_BE_4K works uniformly */ #define SPI_NOR_NO_ERASE BIT(1) /* No erase command needed */ #define SST_WRITE BIT(2) /* use SST byte programming */ @@ -233,6 +233,7 @@ struct flash_info { #define SPI_NOR_SKIP_SFDP BIT(13) /* Skip parsing of SFDP tables */ #define USE_CLSR BIT(14) /* use CLSR command */ #define SPI_NOR_OCTAL_READ BIT(15) /* Flash supports Octal Read */ +#define UNLOCK_GLOBAL_BLOCK BIT(16) /* Unlock global block protection */ /* Part specific fixup hooks. */ const struct spi_nor_fixups *fixups; @@ -837,6 +838,44 @@ static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) } /** + * spi_nor_unlock_global_block_protection() - Unlock the Global Block Protection + * @nor: pointer to a 'struct spi_nor' + * + * The Global Block-Protection Unlock command offers a single command cycle + * that unlocks the entire memory array. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_unlock_global_block_protection(struct spi_nor *nor) +{ + int ret; + + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_ULBPR, 1), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_NO_DATA); + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_ULBPR, + NULL, 0); + } + + if (ret < 0) { + dev_err(nor->dev, "error %d on ULBPR\n", ret); + return ret; + } + + return spi_nor_wait_till_ready(nor); +} + +/** * spi_nor_write_sr1_and_check() - Write one byte to the Status Register and * ensure the bits in the mask match the written value. * @nor: pointer to a 'struct spi_nor'. @@ -1916,7 +1955,11 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) if (ret) return ret; - ret = nor->flash.locking_ops->unlock(nor, ofs, len); + if (nor->info->flags & UNLOCK_GLOBAL_BLOCK && + !ofs && len == nor->flash.size) + ret = spi_nor_unlock_global_block_protection(nor); + else + ret = nor->flash.locking_ops->unlock(nor, ofs, len); spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK); return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index ca650f895903..6812416ab013 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -66,6 +66,7 @@ #define SPINOR_OP_CLFSR 0x50 /* Clear flag status register */ #define SPINOR_OP_RDEAR 0xc8 /* Read Extended Address Register */ #define SPINOR_OP_WREAR 0xc5 /* Write Extended Address Register */ +#define SPINOR_OP_ULBPR 0x98 /* Global Block Unlock Protection */ /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ #define SPINOR_OP_READ_4B 0x13 /* Read data bytes (low frequency) */ From patchwork Tue Sep 17 15:55:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11149139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A45D614DB for ; Tue, 17 Sep 2019 16:10:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81749206C2 for ; Tue, 17 Sep 2019 16:10:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qeDu8MXZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="Y5UrmXWZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81749206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=KjEXoTEIL0ZPATsfobtNNTpZLih3WaZkEmuJD2utcm0=; b=qeDu8MXZEXbwFh Buc9Y0unrtn4iwgAtCdZ0VZzq5YzdmOySkLtnUAV29VJsFruHpo+L6DkqIm2+6UelodyJLMpykgqF 4usuN9ByxUjySQCy7JTwrS+RxYSZEDUlyzC0mH7oK22oIWhF13VRE7OzSUjARicgrRem/TwFuAY4l 1CP1Uc3f4OLCj03JIBXz/snxxVfXMu5gJLYjdB+sk36NALXbSdBXWw1wOEzBadcnBOUzE6IYqLawm RwIYM/WaVrGKaP7BssR0TMtsevrv6YFCx8JD83EP0mxoeRTrfg/flyHu2Q5CLTbpg0Im8JHuvIdyi S3W4SqFuSUFpwTQAg5zA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAG3x-0007of-2u; Tue, 17 Sep 2019 16:10:45 +0000 Received: from esa5.microchip.iphmx.com ([216.71.150.166]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAFpe-0008CE-3O; Tue, 17 Sep 2019 15:56:00 +0000 Received-SPF: Pass (esa5.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa5.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa5.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: S+r08OM4ZvxR9Ida96wL871rGsj86sF2zHZ1lmEVZqUTzgt+5v26pNwwDsxavXX1afwsCWqIXO 5rANfLiXGmweArveB3RFBg47w7IoXFBXxeoUZn6y6C1D8yxy40wRuHv+C1tnuiKoo3qvkC79N/ ghwekKF0gbZZRrRBTvfHz0MrhXpj1oCFTk3UI1PwdjWfVnhZRrtL7KiM3ErH5sQgrpFOR2/2tN be0dQbsNuA0ASd2EAYA5fqHWENGjdyMBdUNUaCbIe7tkC4MIfTrqzHkHuf+ZDYjO1gN4ZH9LX8 bXs= X-IronPort-AV: E=Sophos;i="5.64,517,1559545200"; d="scan'208";a="47827334" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2019 08:55:57 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 08:55:56 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 08:55:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E/WCHoqBie1UYv9saLtUsQRsrPOYO8eqRjcnQpMSEBivSNi4aBZqmxj790bpO2zkBX51X/qmqgVlLn0rkoOZrMcqVdfivmMFVQ8PxNrWn6Qm+Fl6Zbl7w9lAb2w1fmwTmrGTuRzV5m13Er0UC6dsXTnetAtsh5bw3keQmFvb2evKOoA05IJoRbK7WSiyuBM5+iKA1WpCYKqWolqZ54Dw6EeZJBnVUQBsfJ3AmY5n0lH6otIEvV3zXqnxJKwUhleNLlmlwzgkFxwrwvU4Y/+V7ppDWCm745HDaGil8fqUjjjJrVFBgHVAJux0IS1bf+pxJASmCRLgzsL8D2u+fPrfHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mHIiKp42dykWZTwAbwI6qGxF6kr81Xa2SNVhe+Aanj0=; b=EOFBjqi6a8g6pZdzBBReE/Dpu+Ugsb44xiZJYS+rDxlR5dt8P/XtiQd1/y+UiRYTjK8/oEm3ks60m7JdzZsuj2rhURdRcWn2d/Krua+h6O5raK8G09cv/EMSsygVHHn7BTH9iCMZVIvgFXj/ZrOyD1wdA1lPggaDByc/7QxERKykN7+18odlKcZOKrsObR01AExpPni+dglqvJcdsILNRi83V938oRHYa+YpiIJaMKDlXbiIdedcnDQbt/P3njlKLaSVH+hkf73erX8M4sIsd0dVTD2vfcG0E8B7zl5+jDYyuY/pENW8BhL7MzrBHLChUp/pmok14G9oNNZr5b62Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mHIiKp42dykWZTwAbwI6qGxF6kr81Xa2SNVhe+Aanj0=; b=Y5UrmXWZXkDiunJMmg+BPE64D0grBehPrb29Njysu8i37y/pX/9BkyPEizCMrEvPsFqqCIYQN+LSypvUPZRzeEKU5xyID1O4Q6tu5vOXvdbYyNeLg0Cg7BTKLqcTeqs1esiDTSVkjFncsl3d2gj7z74U5nc5Hk2BbE5ZTCu5wyM= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3725.namprd11.prod.outlook.com (20.178.253.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.21; Tue, 17 Sep 2019 15:55:54 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::c951:b15a:e4b3:30f7%7]) with mapi id 15.20.2263.023; Tue, 17 Sep 2019 15:55:54 +0000 From: To: , , , , , Subject: [PATCH 23/23] mtd: spi-nor: Unlock global block protection on sst26vf064b Thread-Topic: [PATCH 23/23] mtd: spi-nor: Unlock global block protection on sst26vf064b Thread-Index: AQHVbXBjDO1Czo3MO0OTInLfcDjFoA== Date: Tue, 17 Sep 2019 15:55:54 +0000 Message-ID: <20190917155426.7432-24-tudor.ambarus@microchip.com> References: <20190917155426.7432-1-tudor.ambarus@microchip.com> In-Reply-To: <20190917155426.7432-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0302CA0007.eurprd03.prod.outlook.com (2603:10a6:800:e9::17) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 215e3ad1-1624-42d6-87e3-08d73b878586 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR11MB3725; x-ms-traffictypediagnostic: MN2PR11MB3725: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(366004)(199004)(189003)(76176011)(52116002)(5660300002)(71190400001)(2616005)(6486002)(6512007)(476003)(11346002)(81166006)(6436002)(66556008)(386003)(6506007)(26005)(66446008)(66946007)(64756008)(186003)(66476007)(102836004)(316002)(446003)(2201001)(110136005)(54906003)(8936002)(107886003)(478600001)(50226002)(25786009)(2906002)(86362001)(81156014)(2501003)(6116002)(3846002)(256004)(305945005)(7736002)(7416002)(99286004)(36756003)(66066001)(14454004)(8676002)(71200400001)(4326008)(14444005)(1076003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3725; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: W2ooYE+qEuTKoM+NhK6tYlPVW3S+jXeGJlrTYC+mORU2z8MVe6jOZsaF6CXMpStd3ihHvaa03Hwg7b8fp8IOkVZY2PqrGP05EF9LOoi5xkaDRSt8paimxBnMUJmVdWaqUHcTGtIDmZNdlSEyDGnMPyWDzJEp2TN3qn0MS6+xxzKoAKzWQDDyZc5hMBzV1LB3wObDrcyeaqRhBAe9AIANGNqe4oPIdYsXLI80kn7Q4xoQt5o0VrH7ie+RUOvTkM7stb/5OjENAW/6IJxOoy7/nHtHS8Fw9PUWadJ9irIvK3Fh6fN6Xe/Kyh0o5etLkGzekGNEYoMuPX5rPPuIgI42MQeK3pMazUeFBD0eyWqMTUuRZhQG8FyEm5Jr89z/6BR60m7yOTzVIGJBc5IUf5STCeibTN+L9+u52FX7T+AFtX4= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 215e3ad1-1624-42d6-87e3-08d73b878586 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 15:55:54.7232 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: m0ND4Adf+ceHxZXxC0fPLvY/UZCL50SrBsWT2HFVRL2zL6UZpgkH80oQJ5fBnfjtpIZdeayr22PMIMW9ZtrCRo3zqZaTiB+reX6DEW6tq30= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190917_085559_432656_C0C45EEB X-CRM114-Status: UNSURE ( 8.20 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.150.166 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Tudor.Ambarus@microchip.com, andrew@aj.id.au, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tudor Ambarus To avoid inadvertent writes during power-up, sst26vf064b is write-protected by default after a power-on reset cycle. Unlock the serial flash memory by using the Global Block Protection Unlock command - it offers a single command cycle that unlocks the entire memory array. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 19556a9dd3fa..19919c9c1bd8 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2442,7 +2442,9 @@ static const struct flash_info spi_nor_ids[] = { { "sst25wf080", INFO(0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) }, { "sst26wf016b", INFO(0xbf2651, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, - { "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | + UNLOCK_GLOBAL_BLOCK) }, /* ST Microelectronics -- newer production may have feature updates */ { "m25p05", INFO(0x202010, 0, 32 * 1024, 2, 0) },