From patchwork Tue Sep 24 07:45: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: 11158119 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 2F86717EE for ; Tue, 24 Sep 2019 07:47:21 +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 0C33A20673 for ; Tue, 24 Sep 2019 07:47:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fDPn1WsP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="roBPlY4S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C33A20673 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=fDPn1WsP5ITd3t t6fTrqz6gLIGR/J33mRrlxZC+bijZaqwNOa7bbQ8ePcpbGmSknhqKJl7YccDL2TvIZDdUxUvD9dE8 xuA8uBnZk3FutMnIgVCScjrIYKJtazNGvnV+vTmW+xzRcui5QvmkqOjUrq1hD4klrnoOUfB0IlU1i hR6BDckPZyh7oKG7kUr1e/dJoHzspqXsTVGZaY6CLM4c92cbi1AMllQMraM4WSMKF4LBNjytrLoQh PqIk9wkmrCZQEGyXKfooBPJK0RmrNp4zX1HNoH2HLgtcYkZKqFJCs6IThyda0UvellhSS4/jo8+cL mqSnbqQwHVt7P3CsgXyw==; 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 1iCfXc-0004sb-10; Tue, 24 Sep 2019 07:47:20 +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 1iCfWJ-0003mB-8n; Tue, 24 Sep 2019 07:46:04 +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: /xOFlMX1/v3DgyJAgzQJPGeJ0NsfBQC2oZ9Q+7YxSbOK+GfX8ND6PEq4bs30U02NAR6yQoVrY0 K0exKHBBHrLfdLFy03im069FBHRuMOu5udlETrR+Yy/gD/NFCGdWEgS98VGajY4HxVQAq1TUEu eflnIOcAGDWl21078R2bns9kPAg87yOdu6OkcuGLmJSRaIww7XbeP6r7k50NAaFIlGEm8aMCrD Whf6lctUl5Q+Frr1GFeiDfbivqQHjLcHYJV0rnsLB7+XNnYpbEsVGbvGfCUw2gisEqO1mdRMuf mbw= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="47374674" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:45:55 -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, 24 Sep 2019 00:45:54 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:45:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G7YfLJusmfyIO6nKIGLriugBMRV/3aIUFIti+5U1xy58Cxv7RYTy8zTHFTa08vTyBsWeDFRZvw7cCSVjM0BhVhYIOV5QFLvYLwOcMm84o0AC3fIWYkw0ZoUwS2hrbFlEGCkbVTfal1J6Drfsai/nPWwhYnKmoSvACYKhlsBX1kJtv8crlJZwjGlbx4izRxQTTfHxd9aQxvZgeXi5CKo64zXq1UtEAOt71pqvhCwRxMiwNBVgaTHRS9U3gna6oOYSnBn08kGEjitoah3JM8H9EIK9cGFbUO2p2unMb8fPVkk5FwnClC3zdxlwyXGF0Or7Kb/KGQ0j2nulN+orBp3p9w== 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=DlARDsgPLHOxR/zU3aRXguCI8In+8/bP1b+NMeU+tuHJmqK0dWfbTFroYpLR8SU5Y/wRMumAsSKN9GS+jWogkV05lANL1SsCFA32RCehJQt+nnYO4MjJZdodKqr1HRUwzbs3uRtDCv9NNPqeXkoZgdnRHfNWGA6oEbru0EwTOmBJI72anRhSFjqRUKMQQQW/68coXc6AMiOFDEbRyhaswkuiajdCuUj5xotwS8piD/pZKcithrLnKWhejKRB/JJ0UC0vE4N6+qw/1C98Y8FHuBLKGiEuKWOI8sIERTfGw0Nj8x8peoeQUeZyv4ury6OPdYTzeX61/IpLLGRNhoEpaw== 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=roBPlY4ShbES+a/Dr1jnWxACwFJsf0yId8ULJbrOrjVK6oSut/VUc7P6GrsZf1DNfA16X79wjSijerAVxWYrpJdXF1IcegEhTe4rthAI2NQ25cIgz2D0rV8kzjR3P5Nb6pSUKkp4vvAATUxqZkWYEU/LG8vO9NG7nfvb87VQTYg= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:45: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.2284.023; Tue, 24 Sep 2019 07:45:50 +0000 From: To: , , , , , Subject: [PATCH v2 01/22] mtd: spi-nor: hisi-sfc: Drop nor->erase NULL assignment Thread-Topic: [PATCH v2 01/22] mtd: spi-nor: hisi-sfc: Drop nor->erase NULL assignment Thread-Index: AQHVcqwVF5z/4vjY/Uups9rQY4HRbQ== Date: Tue, 24 Sep 2019 07:45:50 +0000 Message-ID: <20190924074533.6618-2-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: f1956a2e-7319-4dca-7862-08d740c337f8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(4744005)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 7dOVYYXbkrpZ+fHhcHHaTWbnTMJ87zrknlSxv7RTAtOCuDcixfpEKdcoKssqPZ95VWcxKyYHZRGc0ZKo6c5WL0ejIQ6tgHvKOwIJlz275JGdMuphSfBljHbw9I9Fs80ZU60tqSd8vyVJNZhg1ff6vmahW+ZsNjzhD6IZmwHdqh+LCcKLJzzthNXFGAq4yD02AUqW1T6pH1pPSA/Hi9f3fHecw2lLGyS2VCVFns8ZGQvXRQeay1WjxzNxR91+ZYeM/AL9LHnZQp0qvTJkOX6rPnGTkpMaHvEAWAkkzSeDk8BzZyIxIMe4FrWj5KP6amERPLyupUdZcCRDgQ8gds42X1Phf/p+81kbLwmoxQUezzx6ja+w2l60LzGCLIcq5HGLO/raXMQHPxooWEQg6GB4cBFSTiUdz2vRmok3glENJrU= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f1956a2e-7319-4dca-7862-08d740c337f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:45:50.0843 (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: kVBzWiMz1WQk9Idl2mck2R9oKQyA267YSRp0DfgzoqensHokjUmuC2+5LyVk0uq2sqcgdN85bwCrhyPrMwO5KFVHFJgsAWwk98bUvBMRtEo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004559_414205_6B43076B X-CRM114-Status: UNSURE ( 8.10 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 Reviewed-by: Boris Brezillon --- 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 24 07:45: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: 11158125 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 8280013B1 for ; Tue, 24 Sep 2019 07:48: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 53E8420673 for ; Tue, 24 Sep 2019 07:48: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="XruWcMND"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="Y6HtpNRX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53E8420673 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=XruWcMNDyWcJHG z6ogPftd2jETVsTmtEgTNBuVWlwATzHBUmxwKSBB1/1nLHbaCSopUiI5Ss9H8K/4G5q7ELoFbYFL7 5AkBJgmmTQ48AI80Rqqo4VESQtzzBtox9J/CrpsqkSl/q7lIU3gzjOAXjd0OMO0dc3FUBiXNGjBFW 1B+nOTdOUmRxsdXUN+j77VqKvHI2RVO2XHpzGhDYrPWCC/Azp7NOXHOistCCCduZ3pNJrlzbMywP8 2KKmEuy1wk4hG/Bvx1tniVAq215Sb1M0VQtnfRa+i/yysNZXoUtmgdwb2Y+k28oQ0+BdLDujB/fFU foqzMSdLlHHVGMF26W7g==; 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 1iCfYx-0005tN-M8; Tue, 24 Sep 2019 07:48:43 +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 1iCfWK-0003mp-4X; Tue, 24 Sep 2019 07:46:07 +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: LXSVzPSjFruKQavl8AhFdlhhiCDyf+nes9D+LFhvJh2CDJKknBQUzWWgbuPhWSv82rnimm+Gjn scGEJwGqrG9kUlnRop+fViZqgs3qhnWHhXlMWNfEm3PgFgk3oFHZ4+vhsfGQmsfHkYm/2eCiEZ 0ocBC6LKn+rnFx+41v287WTIEJDbj/6aLxp/M2+o9/u+hFLQyEHoXRhbkQiiM2t1PWjbzgxPGP UdgsIKxRHAmA76oILLrgIbI279pC8s4mJi9A+BHmPeOvmRfwDOehUpCZWjui4lPdNVw4jKwVoO ZOo= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606358" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:45:57 -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, 24 Sep 2019 00:45:56 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:45:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U02XIWvav/urT2yP4DnTUaFXzXoyTufie/jKX/AGVdzkhWhESwp8G37C5HuTEM7FanxJjcTFeJIi7dCR2Uexd/+ul6hj16TOiZ2orqmIaR+Bt1NgxiWrnjhhZJhY7R2/JN2wwOszHdSIRiTf4kxtFwbW08Ix6Z0+BcOfGPz5HX3UCMbginTLbibqsptEMX7tg6+nr8W8YuwFHBlgcXT/36Bu3FQYyKR/jQ9SBgU7/t2zxH2c1x3bF+iGcAszbwmTClhSEVnz60t2HxXb2LCFuWXWevqeFlW2LWdEOaMX3f0/Sqn9U5rFgfP5gvrmO2Zf2Q3AAMAug7bCA2Dtrfr4IA== 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=odzZq3BsyLpKMIHAp9hVkRh+drZe0AfwZl/jQ5i5ouBqQH2YD/7OpRM1lE62maNQz+iHNmlN6QiQ5nFPVKvF7u4QUwnxtNNOvofmEhLaFEe5cXw2EaK2PzzqcXwZjLo16NMcfiNVda5UO4IhhKP4NLSlcL9sl0s9k8AvQrMSGti9tYzWEZzDutLveTHwk+CU8peuL4+PZCc4otrFNaankoQ9731kHauU7iUSvh5qTRFGJeEdgyW230hBvWQXEAIe0WhZC2orRlla195h7rsxCX4sDzG4fFi1q7UPb0hoWuPy+hqlPc1iZP86y0sVFZouUSZHnM4QgZ7qMR/xyKX3JQ== 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=Y6HtpNRXDqJD14v2PzyfPJM7iLYC7D182VXEAsNcS0eDHfKIc8XvN3hd1KkvhCdI6M34YbjD3tNIxwLJUaJ9XEM2OQ11+4/MQQh86cF5lC0aOywTJ2xXIUsPsQTjUjIdaaKOk9jwN9QF2hJ20L+KWlP3yOkyLiI0RqSg39EQ9Rc= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:45: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.2284.023; Tue, 24 Sep 2019 07:45:54 +0000 From: To: , , , , , Subject: [PATCH v2 02/22] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops' Thread-Topic: [PATCH v2 02/22] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops' Thread-Index: AQHVcqwXvwt12P9zSEWzEDp8S155Ag== Date: Tue, 24 Sep 2019 07:45:53 +0000 Message-ID: <20190924074533.6618-3-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: cce97096-e814-440c-546f-08d740c33a58 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001)(30864003)(559001)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: KDj2xA0dgqKxrj6B+MZHtKLW1Ez+0RVSiUTPVzN+NDIeMuAEj4VTliRyGLjs56VHphY01CZS2wEo2G7ufhwWImRPPDRbOatMFFTVvA1XMkfql/Xpqti0S5oGt7dhJA950M6IWHq4zgreph3XPiWdPBlpUAb67S2fHe8HZX0qo9NDqrEMW50qh/Gi7Qu/L0BYELUy7Z/+aoLdneB5tP9GF2FvDM+ccUW37dXZetT/pJw/UYJpBVTOqzAeRiUIEHz+Ktk538n17tVV5mNFgmAG4R/A3rO+TCSwGDoCqJ5PQi38ZU70NGkVjHL3r9BUVEI7itYY+iWenW1wVIcTwxCYRHvbFRfOGkrVJieN7wezx7lcfovtDMVJo2XpLl3sz/R8saFoLU3voZ5Xy9UXKXb/vunIk4Vm18522uWaxKWk7pI= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: cce97096-e814-440c-546f-08d740c33a58 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:45:54.0040 (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: 2omde1o0V9fHOycTklpS8BinBPlna2zHRuMkIR2vFcdeLdd6ed1FVnbvGMDMxlw893bRlvsX385LS59wu6h3M+MQ/U8AfV2vTODZHFPEM/k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004600_341988_D584077B X-CRM114-Status: GOOD ( 11.01 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 Reviewed-by: Boris Brezillon --- 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 24 07:45:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158121 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 D3BDE1747 for ; Tue, 24 Sep 2019 07:47:49 +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 ADB8720673 for ; Tue, 24 Sep 2019 07:47: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="hQv+JFZR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="ILWZj6uJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADB8720673 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=hQv+JFZRX9F+em kxX7Vl4nXjTs0KMvPETtDXhZKsrdG1hFqXSbZ5WdklGtCrhM9NpAEbq3d4gUh8FtPDWOJurY22m1Z bu4oLo84VOHoc8e2CCHAq6hyYlCIgN61cW7LlBkiR4kR14G9+hkgcxuECyXmxpWrYEU9ps1JA01mT P+xWSNQzRaVm/yPlo1fdQidRqhgYPHBCqrfAMJzBQo058E/XiLksiGPozgtLL0JTGKSt6HwYJJ0gm YUgPqCV/52zD/ofNhS3nPQ0WELRcB8wNn1rznCU0hwUsGx+dy7VJqlanSrAGYvDqsOL46UP4jg8sM h8tDPNfzvOQdDwIAxIvg==; 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 1iCfXx-00056D-PA; Tue, 24 Sep 2019 07:47:42 +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 1iCfWM-0003bD-E4; Tue, 24 Sep 2019 07:46:05 +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: qjXoCz4bVuTgiV927izXG7s9mf0pn7zSumoxg6IMG5qoCNq3v3AONDP8RU7SuJFc1Ii6pB2GFH WzeFnLzVCvq/wCrKtZhpOAh+ErWon+qPmONevXFauV6llwpEaDQroSJjLp/B5QCaZW/ZEOq1Sg ma/5Gy/SxBiXMz6ejFtiutoyBWQswp+sd8CUE+L5qDVy1/6idbTSYp5WWszeBEkjVCxI7skWDB gHdHkcYFX9R/pkwo+r6BShs7/UVm+u+zwg0bTR3Bsha2g7za2aKIZwrAW3mDT+VtMoIDBRkv05 wXY= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="50281710" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:01 -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, 24 Sep 2019 00:46:00 -0700 Received: from NAM01-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, 24 Sep 2019 00:46:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKuIkUyJErl8Rn/7ejbNn6KwjgiFaYZr46xfL6Hoy6aCBAzAphzj7ijHC9ZEpS25hK7DlBb4xSTy9DSbVhK8VGyLMiJbbtGY4aNAwJmRCd4z4zdB08p3UtltX+yC5RWGwQCEWtwsyetZZsD287cr/SYdVDVTjsvsu6O+Ho09KW8oMspNxMM2zfVrPMZyDvQAWosasx8Pmv+uHbRTiU70t4Fa5U7tQzAZjYaOKN8GWWPv+NYAnG8psrD6MmgTMMbL3xXyoNa6+5NB3IT+iujf0OKYOOb0tIieEFgt+WuHmqz/fkYjSubcEAUiNyPX//oazklvINZvOJBM9oHhqBbqQw== 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=DrW0dO1dzoQZxJI3OpkpUXBTrFzJZJ39nRMl9ftiVfJLrFIiBIRZjlGVq1duYHDxjXHOnvnZYFi1U1i8knwYR2NJIX8D1BClv+6B5XLg25nC1SkgZIvm4GRBsjlEPbxfN6GJfYpCpcf+D6m/sGjnNltC7RcL4qEbgSqLGgWGPf6MVEaByVpJAuq2AgUqHq7lwjaE+jKL0CzAwNHJzx3wyJdDAph5PtE5gp8ESYi9a7BkrtMGfc0x7aT5lL046yO1+f806vZv74OISubWfvT30GlIysUXIIDyPIHOBtDOevh9xXNE2tzJHzPqa6GztIVepT9RVWxwkO1SnuUdNgYZMA== 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=ILWZj6uJqx8Y+wP/OxGiHaGPyjVFwDjDkIWeT9KiltbESCuUlP/UH8Y2dF9WdNUVidqTb57Sf24+U7eGFcSzlXb3Byjm5iDveWLtcCx8L3jmqaE6jsCyIP/kNihi6SiytozSHHFKFnMx4qLhnXDUnLrMwXC5Q3U1e7uyRMgoJvI= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:45:59 +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.2284.023; Tue, 24 Sep 2019 07:45:59 +0000 From: To: , , , , , Subject: [PATCH v2 03/22] mtd: spi-nor: cadence-quadspi: Fix cqspi_command_read() definition Thread-Topic: [PATCH v2 03/22] mtd: spi-nor: cadence-quadspi: Fix cqspi_command_read() definition Thread-Index: AQHVcqwajFKyuDqBQky8we7iWaMUrA== Date: Tue, 24 Sep 2019 07:45:58 +0000 Message-ID: <20190924074533.6618-4-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: cb5ea043-b5b6-4318-055c-08d740c33d2b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: mfcLSubC3cL40yqzYsb1w/t09QCo9XoiQuXZ0bJt/UWB+pErvP8dEMndEaxHGW5+rZCTOvBp9x+Nr6XO3yxzxIPDJg8rsMcNGSTs3WpNDYwpusCJAA7nLGINo552INxiO51xbzMCB8h++uB7AofcBr+uHmaV+I3SGs1Q2sHquEUkW8JQhYNy3sAaQIDXI2OXLJJSGlb1IVgE6WTJ1OJXWwMoxwJWZiw2I9/GOyrRZ6tZQJpLZtRd+8U+iEmQmNd/nLXI3/UMI12HwyTwzgPrQWlLwHV7hEKGa5JFRrCZQr0h5e3tQFzveGKPiimfnylhTsskAGjbP8QdM7RbSOCB4Y+my+yoaTw6qnOmIWuNcIy0NR/dcMI7IIykKBG4Pe9uvJN3p1LT17QFOC4dMyrSVY1UkoTx9JSPCusgClxa+8g= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: cb5ea043-b5b6-4318-055c-08d740c33d2b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:45:58.9801 (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: pFJvQOlhBqAqfTMPNi4O79Y9+nmKtdZmyHLrXDnBXz1B7I4v/A1UVEIWQ8LE/s0AuexV4bP0Antg0Od4zUSjtH4TrZsqhgl+rzfkTeLzAmc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004602_504887_3B0D00D0 X-CRM114-Status: GOOD ( 10.14 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 Reviewed-by: Boris Brezillon --- 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 24 07:46: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: 11158131 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 D12ED1668 for ; Tue, 24 Sep 2019 07:49:28 +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 986CE20673 for ; Tue, 24 Sep 2019 07:49:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u76QPAdj"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="RZw0H2kB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 986CE20673 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=u76QPAdjrDp8K7 UPUMQVxrVR4YtoCzvHBfGfma9OOhe8jn6r6V5e2Twq293KDynjDiOAG9Us6zif52aO15d40FZaQ+b YIut9BsEgT1p9MnVR9JZcHwY1MsDr8ytj9vbv6ygTgxywVDSRPthX+qRKKFEq9Vh6UYYRM2x6WDZg hBTl1CVN7aM7utsd9JsYsgpt+8vzhHLmTA6LRSiZBuN6Ld0OUHFagWy66CQNHqrSDMxXao+bt966K EHZdzKRUmh/JDElFQUkvSP47oP/Sq8j+EYsO64UkmgMfv4rSbgll4QunM+qTDng0MV/ajz18d9Q2+ AQD16Y7K0DSQxq9IGQzg==; 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 1iCfZg-0006Tx-2I; Tue, 24 Sep 2019 07:49:28 +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 1iCfWR-0003bD-5Q; Tue, 24 Sep 2019 07:46:12 +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: OJpRs2viNkSNlvl7kUEF9H7hA39oEDDyPqmKDREy1/c+rUax+IdjoBbS6KnSEAYl3HauimmPvT TyMnqDExKNe7DcWLwtMNXSYXJM7RL6tvOv8qIZWQPN09UWK6A0Q2Nx+OKaTObfqsU30urrhj4e He7HS+aNWJJ0/2g2qy5tZWp9oTCinPRPRPrKQOz1OWWfXoLMGYfvMLi4rXu9wxkE18loS5cA7E wOG+c3wQhoBeu2eHJw63vaJwvWavFJp2yQzqma6fbZcElbxPBJsaBlRc0rGifjS9UvFijDXxLv TcI= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="50281737" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:06 -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, 24 Sep 2019 00:46:05 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YDyHDVK1Xvm9d1oYWNg39NY1HtxgujJjTtImKD6WqIq7VDIwUPxfVawyNLpaa3gfo2zAnRnnMMMkPwGtqhAHVr9oKHx3V6EE9RmenpKwr+5A6vdDPMtNsOm0peYB667Bw2y/y5YQ6yI5mKAyTS0lIOqNczp0iy97FRXdOpPuE0YiRrmSNDIi1+67oN6CJgJR6Ru0uXt3+i1udcjM6vrfwo9u4r/CBoJxrGD1hh0dLatNZrxpusOoZUPgI6s28sp8XXh8/Whd6m366idUz0EY0sAmBuY59RuQKPFesDiFlQ4PNkxjAzi9N0K70zhJgPjQh1TmIlrCJEp7YrI03oHo/A== 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=VLsWErlcuSTQ8ITUu/vdk5DPLKjx2qWmBKUbas0Wki/hhb3eyW/8lob+E7U3uNNKxVmrKVu+onRPkH+cvN9msnBpRS8l9TGSbjfUAv6ROq90G4xRGX4Tgr7jkhpCgSuzKsuGouvdt98TwzJ9tiJBIErYRwSyJsC0IHp8nSu+yTPLgG9JhqTALE+0UFc0RWFglZ4A47vNcF2CEAK9glJB0KPe9ZNwTSyYqxQU4oDRwWm9NlJccEhSc6sSS4NEjf8lzZ7OxVWoMwKnetPkVtXZPeFpXZ4fTsT+p0vKXtJPONutRgUJjDD2xLeVkgUWKZ106uztAs746rxSaIT+xOqiRQ== 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=RZw0H2kBUXj8l6df7m8XbeeS/+Wue/Drn73Dz5y5NN8SdOdt0rmAOm9EaGoMeJJ0Lf9HMG85t+PixQNjkBCeY73fpgMkOfWa7S9siYN1fWy2mzePJmbidl2XQhM2W7LNRNcOwb+yYLbe8yXrqlbvIFyGZ5zsUv23JEyMDXaBMhQ= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:03 +0000 From: To: , , , , , Subject: [PATCH v2 04/22] mtd: spi-nor: Rename nor->params to nor->flash Thread-Topic: [PATCH v2 04/22] mtd: spi-nor: Rename nor->params to nor->flash Thread-Index: AQHVcqwd6l0dKwpZgkWeyuipcOeMgQ== Date: Tue, 24 Sep 2019 07:46:03 +0000 Message-ID: <20190924074533.6618-5-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: f9510b2b-68e7-44d8-0487-08d740c33fc1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(52314003)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001)(30864003)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: ccCn7LTeL4MDC/M1ykI3fmJgDipyBlHJYES2TGHerXEyzRXUZuVuVmBkpzqBbzz9Z3uQ+fHolLcbx4gs1gfvrTePCrvYQf5OyQmGnn/LvGUApKtadb5dfMNQnjSKMI0waQoHhgKnyDE03hemlkZ1HGaSVhn6Dhd0zH4vx1X6glHDdMg7944auiNulvFsiCvw2s4fdjepTiUsRD6AymPLH9zMS5LukyZZxLm6kkBZwZzVEVLiBT2kE6TF5lGaeq9govxog8a3lSggf4FRbLlupdPYTTiDz0bg/stX17c6VfyGsZ/ewC10RsMQLUvQbCCoVzw/s7vd4AHFSaDqxMx8JmMjjBi6mi1KP1AIOqcLvdxPgyRVsSOtC8DovR27xpxOuAQJI01bYHpZ385dWz0yg7txsrpUhf4SGKWFTDFal3M= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f9510b2b-68e7-44d8-0487-08d740c33fc1 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:03.4065 (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: 9zlixXSOczN4z8YFbar0lERxF9ytl1gKCQmdw/ISefo/tY0o2WF8BbREYsVtJ7gYw6cMxbFGLFwfun3ILl0PxuA8u9swA8zu1Fc6Z8S5CJ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004607_502056_E8B2356A X-CRM114-Status: GOOD ( 14.76 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 24 07:46:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158135 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 3D9951668 for ; Tue, 24 Sep 2019 07:50:11 +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 17D9120673 for ; Tue, 24 Sep 2019 07:50:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ibMplopL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="RYhFSPjG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17D9120673 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=ibMplopLLdLGZa KJqSPesavUOdahrYnxvlAOijx2YkREkW/7v9ZWp2jmk5FvdJHFTSoENEkbQbePyQi3PPNN2Ike7X7 I7HagzEQ607EJujbJva1M5vkKkZXzMUvEF/X/r4L4UdbMsqvc8hS/jM+kp0K6c7u3uZ98SgTvkMnC rmEVfmif2z7nFMoJs6TacW5bXOJBnHZFs99xjsqvRr8YzlJTSBndfG7of49TSw4R2aTSTR2mzF7dS St+lJfabN4EVESk5SvbX852jp280HwqAI0RXkg2rvKkrcmSlx+Laww/hpDWW/RE0jPAKEgrrGFpJd +LrMBELenAVitDdKyVsQ==; 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 1iCfaD-0006xJ-DK; Tue, 24 Sep 2019 07:50:01 +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 1iCfWU-0003xE-PO; Tue, 24 Sep 2019 07:46:14 +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: AKroLHfP+g0yMJpe8jB1S7cCVTxy12qTxz4eQXWNaO5zEMq6mDd1Q7kUP3HQvlMpxvjFga4FzJ 8aIiAkdz28JChnIpg+y2ea1tF6RRT4L9OLR5tFa8DInPaxhu5Qzzra3lKh3MNWjz3ucDgVhVCN wQs1eDg6+qMDj7gSEuUgUMG6r1QDRjKnClsi+qigxyC+0Vk1XjzqTH5uFEryh4wyWziIjBzT+W 9oTe3XC8mVSlde/ixN2jt1WJ7FTOIZ+EBchxM/7EjxC5bF+qFuTl1BJSwH8xKDzXIE9C7u/9q2 4WI= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="50281743" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:09 -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, 24 Sep 2019 00:46:09 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vb4+YufVA0UWiJW58DgCMbpLaItaqCJNrgnX4zip8M4xdT6Q/4mYUfYXzD6c8k4OJIUSYfa6pKC+IgvtqVrAJrpbeYq07tqKRTYPIfSgWi5VthbsDo6qXApZokbbPtS3tD0cLWhxqcyUVL+BgGo/rCNyiVLIMt8DWtylSTQIO/EFYiSRQtngaY7A7hVYpoBxcMwsdjE/Ac7APfjz3+jlCxXdG8v8eQyiVlFaMB/LAoxkZk+35Gdsg7zRJFY18qvBZ2TXM+miKtAf6vEdbiOxhtRAPpBqgNtJgnjbmmrbLCEY2z2/TMGqsQdd8vrZEHAFUP4e35cGyh10uxScKTPHZg== 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=OuwnylsSUzp9fgz4fRkr7T0J2hwsDrFn674ZRuN/Ep/2vYh2XZTmK+z5cUYUHkPIItWQ0a5ateha2mUCFgJcFsvjTfWcwyJVOHIOS1+mZKDTGNAnPxgt3817gTDYEloDc5A5NatN2B97he1aAqH9XPymuCzDH/HQILsWERioUvextdf65Wu8iu1rjWxWcOZrXEbqnUymzgbL9FdqqQqhxCFchFZnaItpU622Qyg9ql7f8EOLVAXIbh4emC39z32VelwoB5Rp6x0nFFLERgNnQdaFiW9q+iG2LqjUmteSSUs20A/xBJIYYA2EbRsJSQv6lwgbZ6qrGfzj3DJOjMUnWw== 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=RYhFSPjGHPi3wCmsLDPMwukGSdNbDbTSsEUbCq74aOuuU5+tBEJoNdFeQGp/MZje3u9LoWggXpJ0PiFWETPu7eGe8Y/0F/tedcl9hpqp8tjhH8IWC6dk1hUf5FWlHQU3IgAbigxnhzcPD5T2zR4DDy/oB7qKpK0THcvSjynhXb8= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:08 +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.2284.023; Tue, 24 Sep 2019 07:46:08 +0000 From: To: , , , , , Subject: [PATCH v2 05/22] mtd: spi-nor: Rework read_sr() Thread-Topic: [PATCH v2 05/22] mtd: spi-nor: Rework read_sr() Thread-Index: AQHVcqwggo0opq7ZEEeQh8oJ3AuUcg== Date: Tue, 24 Sep 2019 07:46:08 +0000 Message-ID: <20190924074533.6618-6-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 0ae09e48-4e5c-4e70-7be1-08d740c342a4 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: Nrh54uSBeRG3XmIDOUtv2qgGewGnDrbMskVR51hE6ZLLuIRS8r2NVUJiTD0zh96UnO5Zfbk4Agx0A7uVNVYDiwcfGpQpahfFcDsQx7eqdwAK/Nw0lb+hCMb98SRjfiMLbzMlQOgOqirjnaKXTdFhg3Atipdpn+Fz6Xdx2EZIre9IsaJ+nLolUAcfdbJqmebnAAVjPmp6xYSJ7P1LZMUyiJJMe1wpMBa2oWpSrk7BZHb5ZjYVAIcW+0pVZrVx3HIYH/zvMQ2ppGx7Pc7pO8bPw7qtMwhs3ma2zWogCpRzclZVPNMlCOhdGDMmcNHxPHQ7aHcL1nIQRxjfN64lhCK/KzhH0PWK8hcp66sjsnUTPG6RxoMjzPjAzRyucVW6Q6Q6XhZ/Jp3Xxmm8B4WG4yWlxu2FspTEAqmMQZVzqHS8WB0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0ae09e48-4e5c-4e70-7be1-08d740c342a4 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:08.0888 (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: r1bwvMTrBTGtmAh4wFZ93My5IMqowohQsYIwApi3RGYbfr+v6Da2ln18B2xbyfJXcozUYMiGSLeOWrYRZFKy+CiePh2PRRd6Gam2xnklhIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004610_989308_07C6FB85 X-CRM114-Status: GOOD ( 16.30 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 24 07:46: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: 11158143 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 2F3AD1668 for ; Tue, 24 Sep 2019 07:51: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 0A40C20673 for ; Tue, 24 Sep 2019 07:51: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="RUlSx+Ad"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="KNab1Tlk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A40C20673 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=RUlSx+Adic/trA RL8xgSmfQOvJj8NLo9BlfkAv/Dx6jSk1R1qqDQ0L1SkLhbXqCAyAX3IFBsNtnu2OZrS0lPGgZkn8w ORcu5FEyrI4qSBi4hy5vCi1HkmNAJ8QmFX4jJb6uywxYY9utsbiNf5T+zvzEvmMD6ktFuEGLCV6DY WbE3CjrH5tWtpFIvJlS1D1ToYCaXvx9+DxHZ8mdDF3V173v6gBkzyLc4dO7k0xrPwR324qCR/mwv5 PoXgLJ9yTKcsgkCjMkJ6kfiC3NSmrcBmBi7/Xb26Wlw/MovS7m+FYiFgmknmisMdhUt7EqLIp39e5 uoweyeGHFxDHcFsQLdsw==; 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 1iCfbO-0000kh-L1; Tue, 24 Sep 2019 07:51:14 +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 1iCfWg-000468-SW; Tue, 24 Sep 2019 07:46:29 +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: zb/k+oSHtr5P0TTMdH8fJU5ex8sFm6w3nfhHaLT0579x2y1iam2twBKmCRuO7FgnU8fYneUPYL fekTL72ylnLhSiQ+UEbQ2U0KBaU81W+9nfYzpN2DCT8B/+vjdxdlI9/nYoFZt/6co963walun7 qJha9DykXv1RWVRt45RVc8moRVQC4ygmPTyQhB+JqDjPme3aDqcLFSHXx33H4rqwEyx+aiI0CV Jxer6WKMA6kaetWN4ntWQvwr0NdvG3hpYthaHl3RvXxiTJG5CHSGgfdwj8DcmNawFUjtQGvsqt r90= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066024" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:13 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) 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, 24 Sep 2019 00:46:13 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwXINIzEMXj6ABAm2q8YhdqwcrR29zKX0zxex3/a7I0S5KBDrvdQ7ZIMDtEo7MJ2DnUd0+pkvgcs2keji33rzD3uofKlnrJXk5FmbQ82rQc50TdGihOaz1HH1xoxJjMtIJizF4RonfeQHAAMTF9QH/5sDmO9nF8rL7rGEVFG/K8Dd7uVszQ8wSvvdyJatlyL1SRrfRhfR0t22r6S3U0NZkOTbyyfhgQVnh3rZGZlGvjpVP2ii/BaD3ECe45Pu07XIGYDu9w08RgeM2YQKiGi38vTspa4YD6l+tTycEwfDB56K1TnHOEUMPVr8YgU+kQucNcfm/goLJHfBAy1k4ljew== 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=XUzzWewKjbF78OkSnYqBgmA/7Patkdx1JoUm3j9xf9NPhyVeXEasFcRACdZ3PQvaOxDX0HXqS5mUC4n37BrpczcUfvGobzboGdJw76CTd0LdwEc0yACFQGIGoJeMuwCK0OomGuUklhEOJ1MSq2H8cWLY7BzEFA8VcYKOaLn9RhIRObstcI3uO9S0ykgyYb9q0CpcbO/9WYqF+o41TzueQB7AIwtt6xK67J3GjYMYZjNViDcDgRjoxuaHJw2+3x8gzRk/9wIJ66VJHHVMtzGuFIe+2048CRRLZauJ40DZ+o8K6DAUkfU34G4OMFMpe6gdT8Xn3H90XfNEH0UbFKllow== 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=KNab1TlkilHL4eO/e1dwfia2K5+XSWM5oMRCpxTGU+by8T0yomu7GHA+vEXlW/GsQY0sDYm+98lbL3M14++XRBBTUTvxrIoZ4SEmvTCTtgnLKG/E6Z/7u+Cyp73w7sLGz2iEgoIQ/GOnNmgrfrb3g1nq7P3/aFo37CEFjkPh0OM= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:12 +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.2284.023; Tue, 24 Sep 2019 07:46:12 +0000 From: To: , , , , , Subject: [PATCH v2 06/22] mtd: spi-nor: Rework read_fsr() Thread-Topic: [PATCH v2 06/22] mtd: spi-nor: Rework read_fsr() Thread-Index: AQHVcqwiPDAQ/vcf40iCdD7mR7ncdA== Date: Tue, 24 Sep 2019 07:46:12 +0000 Message-ID: <20190924074533.6618-7-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: da4eb390-c5ad-4005-86ae-08d740c34512 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: DsRi6M7mg9gfB50NH6IvmQqDsvhjGoVYrK8Qh8YmXzMwJxTTOOv+17+Q1poXyXgBFavw/MsMYQgaJFOXSXGyQJYTfjB+eFzbrXmUg3PGKoFVooLTsj/wsK1xoOAy7Ve/oOS+uEXOu/UfIcaNpKaCR4RSHRLYG8htzF25V5bKgTPHPveKMg0gCyl7uFUJeDxaI/GjGzAsLsfsfI0CvfyQlEszf9KXVhW1N2w+Sfq+RMVgZ8t5y8BqaCHArkBHag8LjlnAa8qHCr7vb259BCjMJFsPutO3iClUBNxtXPJJ1rTXK73pf0+bcOTqm5F8egPhoPpaaOZy4ot/8zEXqGT2TfLAtehfDEGMzhKm5NrT61MJGyXxLNjqCPM807y2uiLjlBpXwPiPfEuVRTQ3hK1sHode2fpJUfC5Ry7QbcgbD9c= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: da4eb390-c5ad-4005-86ae-08d740c34512 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:12.1025 (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: ZaISPBV33+nZoERXLaGjR4AASfS8PrkBliA2saKpJJmqwv0zk6CQ7IENcZpdJmxUyE5nL6SlcfoM8xM7s9LXEcTOSs/z+rGecGZOxCr92GE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004623_215388_01819A06 X-CRM114-Status: GOOD ( 13.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 [68.232.154.123 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 24 07:46:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158141 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 3F16E1668 for ; Tue, 24 Sep 2019 07:51: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 17EA620673 for ; Tue, 24 Sep 2019 07:51: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="QpLS1YPp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="IxCi1FHn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17EA620673 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=+Ei6CfhAhCViFIIwfDYN0AeIMaV2h4cFgL5s5rfKqD8=; b=QpLS1YPpu1wGav ZwAt+s9L6yERasD7/4g4VB8J6oZ1Dun0Pnm8IWFk67OEGE3OflHNFKCfP4N27UJGZBXYWTxBadQtO JhBpRnu4xloq8lW5TKB8nQ3ifINhk9b62MczOUnHzBrbfuRkdNqcjoluHnA3OFXvlcAWdMOtizD6R YkDuOX1sitdb9o+lDqhiL4CjwHuloMPG4ZjJ8mUoZvQ70i0hJuZ0/hkbz3g2wobgWz4eTJE9U0EXm kER61A8yLlBezfyVn3Qwuf7c7Pb01ugOG89fNymTQWZPVFX3Ef7t0S70EJvgp4m7vt4JdiMKfJigG nbLVwSn+vrXRiHCABq0w==; 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 1iCfb9-0000WM-IA; Tue, 24 Sep 2019 07:50: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 1iCfWf-00045e-M8; Tue, 24 Sep 2019 07:46:27 +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: SmJ7QpKXKNvXLJ9o4t8LPt6SIgJ8+1S9zxOrYs6nYmIKgjYGL6YZj3MSxsh4b+22EJ4drTQGsq ahWjH5ePFS9sAAD+uGkRi9+Yn69xOW2/QUgJ5hOxwihJC4P4lRA5WhGMllmGIODYCIdY6uXzQ8 F3VTWKGHePxDPhTU/nkQub9lqwBfpYZGgt9OCk6HgE6cAukFlu9ucthzVFGRBkBaylbgM7pVg1 FjJzCN6ibjxZDJ6ybp1nhmJBX4Fs3hGt/aEAR87g2l0pjfMYWvmiCfuL5nRxJJ88f1T+39RbCk O6Y= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="47374699" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:17 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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, 24 Sep 2019 00:46:17 -0700 Received: from NAM01-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, 24 Sep 2019 00:46:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T/YHaJsv9BgcKRfyhi+NRJ+mJfB73CVXdovnk2Jo6UqzeqRg5wvuUI/tFwDiDA+hqnc5wLuclvij/8yXqRheC0CGHKsza/XofPmQbjp4HilCxyz5Zk7MOfZbwtxMgQKtHL4gf7DNoG+6GrkVtl+KvTaEFUUMB29HskGy69i/Lzy38niG/uRRGTkbpZf10TQwy8gYHdEPlEafe90Rge2E97f4RtoodDBm3MrhDrEj06EYXJBepfmennAq+FccGh0eXSbSg2pb7GNwLLTEGKoveDRTxGqtbUnL3OWv7Fty2810aV2OTQgJ58aENdjeyMHE/JqcbZeGCQPpqBbSWfiq7g== 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=lt+/x8ztRSfWQuFlmFcR6/hiuUecNx96GLlhrSAHw10=; b=DLgsuaUY3gli0F5JI97Eglnb6dbOLU4BfIuW6Za8crBWWIK57WUhUyqJ9/hpLaKj1IBLrLcbv3Z1w6Tc1Ux4adPKpW8zOiyctAfhJGpGmw5YtLlOf/uTZDAzYi0CdoLGYvFhaaRbZ4d/GFweFz23o+Old/NS1tID5/kg7uDwIgyH8jbrLUA3axu0sPr7se0QKl5jcbrNUeun9InyTQaU4KqD8QZqlalLy0B7s7b7hOF4EAucrZFFobSeD85Wpvbk51er/nH2fGUYExQAPk6ixgzbpS89zL4x43XVO2s5nJPTdNdI5Ez5PlQWL/1+uMmB8fdW4Hh2dXpw2gdVSrAjtA== 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=lt+/x8ztRSfWQuFlmFcR6/hiuUecNx96GLlhrSAHw10=; b=IxCi1FHneS83VvR3UMEKgimlKADEmdbZRW6cs0nhOFUb1e6oe3kx1TPmqGSkemu9HpR6suLJC3b3ZIq4VgVvt7Fx+osFLb6nwJWqAea3BuN0vVYwmJuGLqUz9Zf7kkWzI2D4X87TBnVmgi0+mAE3nbIb1E4DG7WDcMp76cetGvI= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:15 +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.2284.023; Tue, 24 Sep 2019 07:46:15 +0000 From: To: , , , , , Subject: [PATCH v2 07/22] mtd: spi-nor: Rework read_cr() Thread-Topic: [PATCH v2 07/22] mtd: spi-nor: Rework read_cr() Thread-Index: AQHVcqwkoFUxWLkRu0iDJL3vrdDzDw== Date: Tue, 24 Sep 2019 07:46:15 +0000 Message-ID: <20190924074533.6618-8-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 0cc4227d-cdf4-40bb-2971-08d740c34709 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: pt8dMB7mTFISVOB7/XeQCU5ors90JVH/auMWjxACLwgDJ9Pmh7Jdaj/4vZweafQWgpHkpGt9MTQVJUhO/rrhjCOW/TwulI1JfhbMSpwHLQmtGhKhUpGoDdPjrDqDDGfNuWNCFOiSKYmJyCxEpVeeqwLlIWxDrYsjFo0tqhzqULxq0lkjRmVPpQMQvMlt1J/6nYqZP9ckFhWp5XGXO/dU7vrWA4lJo4tTHuHfVRMSn1gjaK4VlKAFRPJSqZCF2bN/mHjpvJp8H7Rk/aelZsILXMgKgK4/hHtxQm7fDb82Auuo7PK4HT1y+rvMMJfxxETrrS+d8bfTm8v/+xNHooI11mw+hIH8wF0L1v9eO4/772kpC5RFHi10J0iP+VokJONsqcP45nz2bdvvWZI4zZ9heAlDd39B0cm9xNLvhiGYpbk= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0cc4227d-cdf4-40bb-2971-08d740c34709 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:15.4195 (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: VWYC4KeFz7b9ycKyvlD/F9Ojw/nbty1Q2I3klGQnsa4wkw4AmL57qEK34I0CFQJB2LsMyQyGjwxSgjFvcw9sfXNScopQO788+604VoIZeWw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004621_771661_9EF5DBBE X-CRM114-Status: GOOD ( 16.11 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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..0fb124bd2e77 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' + * @cr: 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 24 07:46:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158147 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 B378213B1 for ; Tue, 24 Sep 2019 07:52: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 8DA2A20673 for ; Tue, 24 Sep 2019 07:52: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="oKzvJzH4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="fkoTieaZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DA2A20673 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=g7y7/wTmctXZErbXlvU2zE7W2eaaek/FyiAZIY4ZDLw=; b=oKzvJzH4MCUM57 mhwYd+Ci51pycEZ/BqThPdAhP2hi+R5uScWRL9b+1Nvgtzxx2iQx2etv848GRCtR+W8jVakIVWQZ+ THERPEHXkrD2of6WR+Wrr/pOaWI3N2maawFZgbqZSug0q5x4X7VMCbak1hEZF7tBuEbk2gmhqqFmW sqnanoWrbHqX2FNR4BQQopFyrjBOdeQQqHxS0v7UpWe01goqtB63MF5++c7rUq9OviG/heLkDqAoZ nzMJfP07epfE2yxLdOc2oYxkRoXHqeeiLn3J6xtdfKuHdY13yYWEcZ/8XO6wE8GnrIcb4JkuM6yu4 wlXABRgP0FjBwqw8AClg==; 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 1iCfcR-0001T2-RK; Tue, 24 Sep 2019 07:52:20 +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 1iCfWl-00045e-QN; Tue, 24 Sep 2019 07:46:31 +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: ij/cBcC3nrhFXU6QH0SKP/u1cWiCPsYiI1/1BuB9KdJ6B6swPG673JS1MG9Wd5aY08t76XW4fA ZimR81Orbe1V1TPa409mKhYU792xApkRBUxlkAczXfE6CHtZN65QaLjROhU8Shms9pHD+u4QD0 87MzngOeHLWrITPc/8MzQfgqwXyBvs5kVaabUSeofODhzr3DamOnev1ONpvqvg2riEHBjiMNcB aOi1jQNG+jMzaJmyd3Lr8FZq+SxBgEKjRcVhw2KF9m4XJlId26cLRUZvLv22jx5gl56qrwqudb qJU= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="47374710" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:20 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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, 24 Sep 2019 00:46:20 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pz6wug6vAgzbN4QKrDJ77NqC2hf5yZkeJFS+pAfvmmw54a0DMDONVhjwq61svcNfYsfOroNtsXzOFJxMIe6IDo6Rz07nyIoJ/JVUk7wtrQL1Di2KZg3tT07gyO47Hs4n2wJLzVN5WBnD5F/EelzwwLCTj4c2GfvEsOc9MA3tSqZU3/4YrlZAJxFZ3GjoD2s6BA1I5hnx/eJ/UPv9eoJgkLSGGzdeFJucKIp7kzWWy0L0I7SwnLDzTOpTnxLNjw4Jw/ztbuLSIgtzwScGath+vNuMciDY7IHStrnD5eY7D7NRucgaaKVSg/okk7zFM8mpJ7RQEC44dV66f5tXXRzgVw== 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=EgNYDQ07Bp3JUOwbUfM+5F44GdodnP8PvxrloxpbJAs=; b=ckm5zwW+U/W8n8wDOE5xliP7qTlyaoXo73drHs9yk/21phiBK3/d/WidBlzbN2svrDoKkDwTj1I3T+tEoIwTZwbk3mDFWy0iTfEKEf+M1kkWhKT/Nzl4TefBO6VAoPhsuqKYbtEPgjxxaN4HXT6oxAXvlLqId4ubNvCfi294nkDg85ohzM8Y7t173TlF4xTaAk9BxdYt6JafIUaREmi5oW9G9xpfPXxn0V3lHXT0Bf4P3jPjdD/7vTtnm4+PO9Hk+HFdgup0etwYZ5Q37Lk3v4jivPlWaLtI2QbZrNJWcD4bzpJxO6nyXOgJ9V1AZ1J0dbge0R7zVUi7hqlTczN81w== 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=EgNYDQ07Bp3JUOwbUfM+5F44GdodnP8PvxrloxpbJAs=; b=fkoTieaZrHIbRh/8b0KuHwamk/oTLNRM7bC2fNBtHfMWSrCdTfU5/Kph6E0Gv9/iegRSnjh2NMUSZXmy/c8fZS5ncCMheJxzahLs5gTWnPkh6QX2bcpIzi1MUmHce5poG67Jzrbp3TB7RH2gv8K2d8mjTHhyn1M8Egqehke8k7Q= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:18 +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.2284.023; Tue, 24 Sep 2019 07:46:18 +0000 From: To: , , , , , Subject: [PATCH v2 08/22] mtd: spi-nor: Rework write_enable/disable() Thread-Topic: [PATCH v2 08/22] mtd: spi-nor: Rework write_enable/disable() Thread-Index: AQHVcqwmGxayarzEFkyHj/sWgnNJNg== Date: Tue, 24 Sep 2019 07:46:18 +0000 Message-ID: <20190924074533.6618-9-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: fe1bc4f1-191c-446b-829b-08d740c348fd x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 6UQc0O3Ob48ImuQo8PqZxeQwUUYW5W+esSRLlro9VxaBMyneHJwyqK+A58lRAX3Z0XNH0sRsfJ73ooXUJT1Bih/JYWjHdwHiTV/Lzp3KxlY5vZrJKYqPcEdJuN0eRe8zfLk2MDLkl4b0tZ2qIrWLMLBR+IXbEw5YkqFyZRuvfZQA5O6/wZPMFkaW4oeMQ8pI+vVDuAhnzJFyO0OoePrNakRqDyjrFwlYEdVZMhcZW9X7j0T5d2Wb+bFFymKYrT+1Vpt/tqz6rQqUDB35HfesYRhRf2bHetpbpO1JeteSJ0lqkgnr7tjswTPAeRjZrbd20GlF8/KpAdjOgiM1xTHQ7vlYBd7oSWK5ivD2/bjFofVX22L0L4GQ5cp2uNccmdULFx8HzYzy8PSazhFEKaEtgsNsiNrPHzBO5Dtp32aYy4A= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: fe1bc4f1-191c-446b-829b-08d740c348fd X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:18.6176 (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: APKNyq7MaovMYI0/TLIEdYplpoYKXV0h6cATBXJFgZeyf/SEbTpayYEKnpyjH+hr2XT+UvRPNJQDU5oc0S5ybzP8dc3WqKn0c19RI+6je9I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004628_024695_47B85CAD X-CRM114-Status: GOOD ( 13.58 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 0fb124bd2e77..0aee068a5835 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 24 07:46:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158145 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 BFC5113B1 for ; Tue, 24 Sep 2019 07:51:34 +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 97F7C20673 for ; Tue, 24 Sep 2019 07:51:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z1cZVe5Y"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="PKEv6tkU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97F7C20673 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=EXx7k+KNa5V0B8OAZz3o61aOF/zEXVVY1ognsfGl2PI=; b=Z1cZVe5YAllDdB 3nyWXS1AJbuLwcO660KimfyQk0Irph4qLV5NrebggktgFV7pIirUz5sVOteKahw60HAAzP+73fx8B LJNNQMKPDjVRE0gltMxAKZ7jITnaUQlNLMsRK9m1BjehhsmwWauDWXYQtRJXFhtTf0LGVx7v1x8Y+ tXCr2T1GM86oh8R51YL16In7fCD7YupOhiXWS+C4syuiq5dxB4niYfvyMNfs4hprZsimthKZNoVGS ZHtCG/EM2MhU0FMaYdrgZugVEF6eNObDdVGi3EmzOuM/2cdGp18WDgs265weTGelWbVnFYU44wvgH +1mPYWUk8MVijZ31d7fw==; 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 1iCfbh-0000yl-AP; Tue, 24 Sep 2019 07:51:33 +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 1iCfWi-00047V-P4; Tue, 24 Sep 2019 07:46:29 +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: AeeKypm3Xj/W1eNi36X2wMUDgg+HYWCJYiHRscqgxOyoo/lmaUv6LJf8RFWQqKDcqYdHvMz88l wmB6Uleu8NwmZMBDElB3Pa6ReuAPnGW186eEfgrDZ7iWjQ5u9KsUKWLAPt/fntG06dMh3l2sri nxvo4vathy4R7jtiaYz/mQ0wygiPFn/cefeN6c2niFEdPwB/LY/+O6C8mX+Ghhv76FmLMkS2CD vK4u+wiPsYHUxQEkQm8m5t8OraXwfMziILS3AfIv9t+KnFq9lDl3+vH91KZebikJ7+eRp48Aw9 +Vw= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606460" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:24 -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, 24 Sep 2019 00:46:23 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rx577mspXttT/nG+BrJgncgqlH6qUCS3IL/OUnFg2th9G4lpZ/WBDvsA2UZhnubM2gQICsaIE+X9rUpUi5hLfLVtKygLscEbKic0297renVylXSXBg/LL3sK7+KHTGoiT8lElTkvyzChrCGde7YYPUlOugTcstRu9iyRiAKtvw2rdP6rWn8kgBb37WY1hyCwtsLiQNgPe3Vj7kwlMLSIOGbdMVSCWTqZ8jdMGszCUH5D+ub6DzeWB0ZHTFnqReMEIxZXiggsr9VLM7kZi90gvpjtyLID4SYGDV96gXmBv+EO4MtTteesRdQCtLr9/DwAZjmmTydiflDJhGeDQqAaug== 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=13mIgWj2Z1NMMHDpfeVOINAzw2daSFAmJ2a/ygFXfBo=; b=UNyQjW0iPdLVrk4l8O6a+9WZNu1BSsavbZRgGwT9juI2dio/cifje2Vgj3vSuFX3rZnTZblKVkPcL63hdzqECijqgCqOzg1i/Xi4lRPYBquuS2qIEwtiwSYUSzydVYrVSe2lIHgfcrw/7ZUAWbaymYqsl+9xecsZuuQHbKQ22cA/50us8rt2XoTXqz1IxdkHcbPkRg5mv0mQbxJj30yrdNpenVfH7zUr/LzSEAQUn5RrwJOco+CIk9eeFB5rNg2ypY7LL/AdBctiTNw0c52CMH1QzX4fdwCZnN3+aUd+YcvtKv890dmWuoBHhVonLsF2bv4fTd5s79p0NfDEM7kpbA== 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=13mIgWj2Z1NMMHDpfeVOINAzw2daSFAmJ2a/ygFXfBo=; b=PKEv6tkUVma53PnxostQQwkNhqP4RgY+eWkTsz9zopGmhTE0dQnIwli3x0suFNs7q+YBfgwebcPYCk1uQVnlxSJZTYwnXTEnEIJ2Z/GqWE3yt/uCsK0ItO1FgQXDTmqCyQlU1BBKxM1zPysbkGiDFjTto+KuzRP5KlXiMsW8/v8= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:21 +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.2284.023; Tue, 24 Sep 2019 07:46:21 +0000 From: To: , , , , , Subject: [PATCH v2 09/22] mtd: spi-nor: Fix retlen handling in sst_write() Thread-Topic: [PATCH v2 09/22] mtd: spi-nor: Fix retlen handling in sst_write() Thread-Index: AQHVcqwocr2G1vTqBEOgTu/C0BezHA== Date: Tue, 24 Sep 2019 07:46:21 +0000 Message-ID: <20190924074533.6618-10-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 6b336001-b099-4285-141c-08d740c34af3 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: iObHnYSACaX6WYGTueeLNm6muhNE0ghwZDWq4d2+Pxx892gtkQKlFLPbb2W68mLxPy+UpXwCRn16y5G00cT958y0r6M2t4HKiYy5gNiKem10b4kD+0BpSxi/thu3dZ3xluJ7o745vGzciF++1xSgpq9FziCXQouNgcad7C2jIxwc2KZtt55AI5KgOdOinBnt5DdxOrPL0TzU/PTKkIaUU/96fU/rNmhzf22xFd5wIyqL/hKyhLsL9UY2wdIm5RmyVoIQJ0n21iaklvKqa52eRcTb+YaSH+0cp0tBH+DSpd0iZ35qcFBhPQLUCxsJbv3fv/ShVJf/gQGFZL1ZJAJDxtzezIH6bl1gbXzISkTeJpkbp043AEkjj5qWHj21aKKTf+9J2XMNqGNMU6VmhsVOmULGCSE15QtSBwwdHCOSVC0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6b336001-b099-4285-141c-08d740c34af3 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:21.8298 (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: grlkVu7aXMILsCTffjnes7Y6copDMdfLNyH3YzTgYDdJ+4HD6TG82SbvL0OLQ205QkAsGyIiqN++YLPIKdwD12/xJZFy4Xs7traHYBl8cQc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004625_266136_D64B1FB6 X-CRM114-Status: GOOD ( 11.35 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 0aee068a5835..be5dee622d51 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 24 07:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158161 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 57ED41668 for ; Tue, 24 Sep 2019 07:53:53 +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 2F67820673 for ; Tue, 24 Sep 2019 07:53:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Oet3zuSN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="ggji2e17" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F67820673 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=/2HGF3+//rCNUSvCvxCwbEEGu5DSBFep2biu76Ay5t0=; b=Oet3zuSNZsfvMC EMMfkDeO+l0QR0gE7toBldMUOD2eBqqPhjV6noOvLnvD2NWgJeIvkPsaTubUzmG3upM9Sg/uP3oyG PEmSxF71rmUQtAlAvPobK7tF5VGN4NTVikL3IajMWYocLjDVM185Y1i8RFVLpHuLnEkdNG9uA13Lr M8VeoeXcqvJYlniVeQxdy/JfE6wFbK87wvaRrEdXzpGnbjLuNgc/NWa0z245dm/lpdM3vVO0trrRP Egk7WGCOie9ho+jAcW32TDQ9zrV3WZvR8CdlP8ACsLSGxXrfp8iRx/LdnqqlwljjS9wlidqQV48NB 5e26ATb7idKn20ibbE0A==; 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 1iCfdw-0002a7-Iz; Tue, 24 Sep 2019 07:53:52 +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 1iCfWn-00047V-Ly; Tue, 24 Sep 2019 07:46:33 +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: Ic4vXQkrOu/3LaUB0nzGCURRGXRMNsPfpAGlsBtzrwSup1lZuKF2Eo8/fjgNasnuln4wqfCaQG FRV/mYq0yQVx2DBxm3bkPwECnl4UglRpjx3x1QuD3H6QNh2ZdnxES0dTzVMqrgBzxAH7phpisA c99tqLVHJzDJvu13/m/rR87xhZizxvnIgAT4DnsYwQmGLAf0PfY7bkyMzw6P24+wR8bJC7Dl/U 8XlJVtm9/Z1Ip1mekoIQgXRjnFqc90l5oBZn56df2Bs8C0Xwtq4FyZ9xAeV/ONtplKYKNi477t Bp4= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606487" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:28 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) 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, 24 Sep 2019 00:46:26 -0700 Received: from NAM01-SN1-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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JqLhHdtVgAnVFbiED4ulixgMIrNudaG801nwuId1Ikr9qlekoilGofECMz8sGWMI/3YLuFvobOxv1M3nROb19GX6+TPFfWqEiinhh9jNu07UN+IfJJUbamAkw3Yz5nu6aMyfuisq0vZAq0CUTLowtPIm94HEnMh/HhdyAWw1L4ZQNpGcle6oTQX2QW7Q3RnPUT84e2MVxrisJjE85luMXNkbgRxDbLqNRdf8k5A98f2WJYuJJmNA07dTXznG1oIpPqcg6VUyJTZkR+4XYHEMe4ccyorVor8MNwJSIuBOABfTjthusQJq9pu26ixQR+zM+WtG5YZoOzTY9vSLDSluZA== 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=7LfroKdQIZ8fXiCs0JFOsT6JY+CtZPoYZmCam2YXviE=; b=hl18m8hxvqXyEjDUksMA9HtlBqvbpQOPTf1rOkbnz5CL5Mexn+JOeaHofrnvxfpti3aaTgx+viEKqYJi3RNdyRHHvduDhsd38FWG5yP+VaeRVymuzJwP+StmyytNbhElLwuJJns0l8MpePEQpAkNhkUtfI8pVpJs4bxaBdgPp6dE+mk7W9r0mgUcU1oOoSlQbbXLOzBqWc86iYYAHXhdrGntMLflquOblNiCInDl7cCYUkikXwsL4BXDHhCXL5fjBdZwmTZGMYOdf3kDZwoceMNRmaH0VD5t8v6eYIHF0jTuNOZyfoy38NHhu+C4UOnmP/3FNkhT61Z6Bc950nFx2g== 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=7LfroKdQIZ8fXiCs0JFOsT6JY+CtZPoYZmCam2YXviE=; b=ggji2e17u8CE+20Ymnyfb1O00zo9YIjt+NO44K0DsIrcFD76r1hAToXgq+G/jfh9o1DdLERiomH4Zrp1ZMsoIlKL5K8nG/1pDuvYpJ9RvkGXsbH219yPjVm56SeLkHdkEy7yB+V4OAfzytZGHOriEtUxhy61+oJ0qABvLDYmWcM= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:25 +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.2284.023; Tue, 24 Sep 2019 07:46:25 +0000 From: To: , , , , , Subject: [PATCH v2 10/22] mtd: spi-nor: Rework write_sr() Thread-Topic: [PATCH v2 10/22] mtd: spi-nor: Rework write_sr() Thread-Index: AQHVcqwqkYJhMgq/4EeXQwoXNBbOlA== Date: Tue, 24 Sep 2019 07:46:24 +0000 Message-ID: <20190924074533.6618-11-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 224ff5bd-aa92-4ac5-912a-08d740c34cd7 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001)(30864003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: MDVJ+iCl4dTOQD4VeTpZtCQyJPgCWpia2BgBrFTfgaaoQE6sjwMgVFgikLkQG/bDTsWSc/3quRrH6scDgzkJQwxAqfYA5PFks1c1aD+MyBVfzPV+DTsUqbU09xhyxF80U92JhSsKXC2syV/RBV4IkqtWoN0r2J30DjYFdyJSdBTkqeo/YDh4Vf8qP02iFzh+7NtlHa+/Gg3H18Vn7VP+tuAQpF7KxvlrxRbRT7iCMEpwm6arcr5VPfnKKCXQj5QPVe76tfEUHrX0njhssc+5XoldKLHfPMwheExOtzoIrwpnR4MNgLZ1Z7ii/U8LTff3FjoaBoS3uKy13pgOenyIMQ7CXQV9gd1X9c5AL8xB8EpGmAoXRLGe7F8SYa9hJOFNP6smrIEQGzp4cNBqPS5nB5uvQ6nqggKLfzk/dCyzEn4= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 224ff5bd-aa92-4ac5-912a-08d740c34cd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:25.0309 (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: H018xMPIGUJ8oOQSGOF/Jn6Doe0cojctFEvsXhuxVJ9fDDSzeXo6Y3iaHc60cFBdtLMDuFuCz77mpjLzJtSIROkiUQsrO6YLahyiJTljbMc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004629_772850_2F9DCAAF X-CRM114-Status: GOOD ( 14.32 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 be5dee622d51..31a4622d1eb9 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 24 07:46:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158169 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 B550413B1 for ; Tue, 24 Sep 2019 07:55:38 +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 8EE2A20673 for ; Tue, 24 Sep 2019 07:55:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HUErGc2n"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="HzZyp2tw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EE2A20673 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=tWRWOPJqspjrft0WKYnUP0IGpstSrAVJE2l71iALFig=; b=HUErGc2nzGiPR7 3dswlVRANnkihV3yu7agKsc3dbCEmRXWUsYRy3Siap4yfL4VHaZwHJb6QFjmrMZUXWQL7nNXkRwi/ RxNFtcGjXb0mTAIzqRjCWIOmF4WxrJobIf3BWI0OTV4ZirkammFToeagFXkA1ZwvJRQ1gf4W0+6x9 D5HWBiqG+L/ZFs+qmJPCuq+/nSraPooYn4rr4YIXeQTWWrY7D3o4SMYtcY1ANYk+1zPHRCheeIKks Tzu25Nv6qg2l3/+vo+JwBVefKdS8dkwKkU8v/P1YRcvWtPhZLZLzjbtlr8Se90Yvp8TXUP1jUJlqR K9m1yEBigM6ReUnY/EeQ==; 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 1iCffX-0005F9-88; Tue, 24 Sep 2019 07:55:31 +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 1iCfWw-00047V-E6; Tue, 24 Sep 2019 07:46:42 +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: SiyliYSjsFYsCgmOqnFs4IDQwwbOsKxw8nGFQ4SYTtTK1CXrjIrlx4H66blz3YKSI8ktY/4nuh O5h5HhfZ5Ix9pAeSu0wlAvF4uc5OB0wQr4FV1nbfTenrBdcL888LlAleYcT5/oveBZYUa5D24k /bAIK3CNcEU8ziHBfskGhfR0P2bTyKj9gnXW0PY8K4hxeAmSl1XQTrWWIkUgZHmi2Hlq2Dyt4r rF8EPqueIwbrMQFLO0FEzblixApl4KoYMlryRxyszqivMCWj1ZlQ91TfsnzKTqRd33dXqYMqpO CUQ= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606529" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:37 -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, 24 Sep 2019 00:46:31 -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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=myXiIUbvSQDBICrM8A+QGJa6O306se/i4l88c+BqEviVsU3uzcNxxCgrrjGvYB3jcxYJr/7oNX5Q485VAAWDQzE2Set1L7iPV7c92GLtaBNUKFgDpFCY0rfrPnw+yr/+fS287lmY7PKQ+bR3RJ508e1E82tJm0w5T1mURIcnmGv/s9jV0c0IPao7q2F31Mc1EKpj+qoMF80g/H7oYl3COFhfgvLsXrNwhVueDtzkgVzQzqGDxEJFyjdxIhLSNsh5ntrYAmAMkis9jRGBJc+z5ZX5KEQrIo7yW0t7r64Wj9Lb8Trag1PTKwPHiUNzYiIMa5gfZIfts2HdHytohD/+eg== 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=rP0sP98Sf2HxaEgnnEQ69H4ar7RhoPr/39cIaFuAF6s=; b=IV9OHLqwo5l3JU411wiJqk/KGv05JnTZMsxtUtQ07OFFyYznH0ncDrq+i4U1uSF5fndbMu3uXcE+M3uxmaidISudY8mDTsezQwLo6ZHtS+kdmrq30484g8RlNFOuQZnkAAshXkrKW5ZwZuU7TEiqgZ2kjWt0kdNKiTtPJPdktv7Tk7SibNktD31c0+7/hO8g/tJQZmE/BhH1zvpHKGrxMzhTynL6ovkfb2oFfafooTE5MfjBhv3N56s4sQsfKQNHJSJvpRGyOxB+wrQcwNuWNURa3Hku1NqZcWHMC14oXeFWplDhOBy0DlWK45agISKsJizKqVLZ6ia5fsUXihV5pQ== 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=rP0sP98Sf2HxaEgnnEQ69H4ar7RhoPr/39cIaFuAF6s=; b=HzZyp2twRzlFX/6E9WGiRRjOOjBQjzNlFyO6xQG0K7LvD3Zvb4OdfO3QwAAoyhzQWVZCzfWlGpJgK8mxwrZSGnEEgfjcX3wCihNLWEFAmOjHTR22odhEvqgOcZ1T8nItOCfi8di9ToXKVlwFyI6H3Ap5BPLAIg0c2EAsLF6srDg= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:29 +0000 From: To: , , , , , Subject: [PATCH v2 11/22] mtd: spi-nor: Rework spi_nor_read/write_sr2() Thread-Topic: [PATCH v2 11/22] mtd: spi-nor: Rework spi_nor_read/write_sr2() Thread-Index: AQHVcqws4BSMXyqrs0alxYsMfkKjqA== Date: Tue, 24 Sep 2019 07:46:28 +0000 Message-ID: <20190924074533.6618-12-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: e3155a01-5dbc-4778-2200-08d740c34ed6 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: AUvf3hrlVxL3dS/MTWM5C2nJHwWQcnh2WKE+jLgJw0a4ZOrqo7Dk0mdMWq99l1Nf0ai9tj2ig+ICnpRUEdaz+aF3OZL5P/okQXDG1i51AbSdhrr574eMaVOLS4hWwuWKQ+2I86Z3XW3gIiNKs3xBDSiaUVpqUzsuk/JYGUytyoGcduJ3vme1epCI7wWupvVbct/nBRqQ+k/K1yJDIR7aXM5jqVNGP0Dio2vDELGDcP8JjB8EZXFvEpEJYcxceSqXJNk768Lks9OsW9bh1lzvf57XcN2d1ah5oUh185doIiPhL56d9a/wOzBJv8uMW+whF8wNxZTAvxAVzn/YnBRP1Fkf3EgQHYKCmtjqrZcFdppSE1/Y4kwGbzNbsCgWYzKwQNWM1P6M6ckGZKoG0bz4fwfxoQNnrby6nya6hsxZc/A= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e3155a01-5dbc-4778-2200-08d740c34ed6 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:28.7048 (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: P9GnJMsxFXWq8/IdftvEkJqN9khyNY3I0ZVPwEg2J/u02R8TCKk+adZBr4zGp9SN3ROGpi0MHh7pQbln2mmitXEHxQvn04UDWiWB9H1D7fQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004638_539031_AAE1258B X-CRM114-Status: GOOD ( 13.77 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 31a4622d1eb9..33130ee84164 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 24 07:46:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158165 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 9DA311668 for ; Tue, 24 Sep 2019 07:54: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 7A15E20673 for ; Tue, 24 Sep 2019 07:54: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="CAxTters"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="TWy6KgS3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A15E20673 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=jsPnhWjnK3x4PdF6UyuI3b6Qr8owwWS+DEQ7vTx2y14=; b=CAxTtersHwaFcG L41fglAZbNcFjcxnO71+N3jW3L+hs23wUPNR0i3RX1LRD/a9GY1drC/xFDb/Zx3XjkBbxgbMfZDdx 6jwzLU/FUTxh3QS5af8Fg3D+vy9k82pwj+ExnsSeS0vcLYEA8CnBVWs5EqGuUfHiU2p1asL/6FvnQ Sk1/rEVGan/t+u4CVSxMRZC26kRTEEKupbd6tujqWx/qVcg+nRfOK/0F/692eUD9a4ww2eGv8QtjW eDw3jnjGEW5tput8fbmrWvwSBR/dD9LCFqZfqb2LVWDP1WseuePgEOONXIRlfkJdE2hEkZoXFlfhQ /lrsoMCt2KMjtd6nZYXg==; 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 1iCfeu-0003Uj-Eu; Tue, 24 Sep 2019 07:54:52 +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 1iCfWs-0004HC-VF; Tue, 24 Sep 2019 07:46:39 +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: 0Op2fUshFzp0tyDSg2VaJQonZBvOeMqF0/oLqxbckfWhgNIeok78sRP0U/R9+CWj2fmqkBfauG T1c5CH+FeO9OmrXs6N6co89B02ntB/lPsVZnuHcbnjlcqIi3Xj9B2zxSyDZ9I4JzW18cMZDIAS GMMmxlafTlreqq9p9cH5kwOgH/Q/ocwMnhBcyki4A1QTy0P5hhUfHFY2rm1oSKVhFIdthE3J15 3CPk1XggDYRvWBsy69iDG+DoS5D37wh3lySR1XBej6DE4XRBWTx3AOZCWRPO2KS1uguQ+9n0HI +EM= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066127" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:34 -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, 24 Sep 2019 00:46: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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HrXZTMTWNOxBPRlSO2wozRsYzEztpfeepefEtUjkHNovtj2NLxpy3aBlv+dl6sGtDOJ7NuUcQHJUJSv7hJVleKsoPJ8AZAySQIZa6lp+SKhifLqtC8N0InWADkov8GkB0FuM4GHelHY+MKI+c0WsXFmU0/7auBl86aqMvaaPDpTD+HOn4pu/qS112tcePmUBT7yc9/0c3M7LxxsWjBhJUvbOL71nDHVzGCZC8I1mPoUQ4Hw0N9fPVcvQx3DQpDUrcF7Kw5XZzFt22Dszf14pFOWHWcHScQTiBWZB8mBslCo6C/XwXTZjOs0jPtncMknbD/J52Fc1pEXn3aiKLAUD0A== 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=37z9nc9ls+nmKX1SdTchBNHEq6NK8HEGio2Ib4jGAY4=; b=KhyhkivJQ15VxfENml1frHX4UAI24tLeaVYK0Hlsc1pdvU5C1PTI702RjHL//a4IqvNJy1khn6PDaiTCNzoJizJEZ98UspOXGGzzxvBQ5fgyXYbmuD7iwjvRWqBn5OFRTC4zyKKsXFRYWZv73nYRwvAxJ5NqaAinolimWyxA3PXSJBkTEACXfeQYxWnx95Lj+2XIrXRE39xTUziketQcaVwbSwNepJpp7yPZAtlMOYBV1ou8iCtrsBdZDRfggeZN9sdpVMLXhbWHzi5skfd4Yfmx9j2EfkMNtB4HK6BCKAJ6W2465YiLdu6R/REC9iGZdyipaSQ5wX8j/2RBnpfZgQ== 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=37z9nc9ls+nmKX1SdTchBNHEq6NK8HEGio2Ib4jGAY4=; b=TWy6KgS3JUhv4mQ9ZuFPFQsOkxOkL5tHt3Grqa7OHeWrA78m3JS1lg6xCfKKJpPTx7LKCsNOz1E/w+j4mqnMF3vylwezY+7hcOkicARl9SP20OVaL113WV9XOrv0jTSmLv/N2asWiP6S7DS/lXZ1H20rKvHTO2Br2CO077Wit0c= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:31 +0000 From: To: , , , , , Subject: [PATCH v2 12/22] mtd: spi-nor: Report error in spi_nor_xread_sr() Thread-Topic: [PATCH v2 12/22] mtd: spi-nor: Report error in spi_nor_xread_sr() Thread-Index: AQHVcqwutlEKVRtIxkuyc9Dc3NHoBw== Date: Tue, 24 Sep 2019 07:46:31 +0000 Message-ID: <20190924074533.6618-13-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 35c120d4-49da-4f1d-c9da-08d740c350fe x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: XrDJ/6JECSAfZGH1MpS+b0iqIrOqLR3Za0d/M8+7SZ3/MHXo9ys0gCqxQ9Et8QbZ0BevOlJ0Htr+7/QzvgJTKvy780baeVGR2Z3Qy/4S7gCRUM8/pVn0zGZkXmJRgeGw+1BI6ugJdON7MOx9ASTi4xvxTndncbVd11GAojtBkO5hvqUk37CRQL0cqM6A4HuODexLpJWKMkRjtrdfb7g6260s5Y3FHY19jVoBDXGTxJ6ta8lBJPAe+RPHGtGIE82KSEOlOTYjgYkby5IIvaQlP4Rqa3gUp3dx3sAgD3SWCcz/lnzbbNDgYfpiv9K6q3dF1L603euYrAHdNnwTTqtUfWwQTNZIt+W9IYKIeDQJVUEjxWnGCoR0PqgB6DiGGHNvfnEF0ORD9j8AHiL1Mhf0xmhPR8Tq1XNCoja/9Ybmmqs= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 35c120d4-49da-4f1d-c9da-08d740c350fe X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:31.9119 (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: dfQIUN+XDLiy2N1VeUMynU80Sp/BlcUqJ2GfHcbAQYs7dPi7j7x0jvQKCYhiX17KqNM/h0DZrRXljuK38mXc09tdu2B9ugDNh/1kTly5Spg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004635_305969_239082BC X-CRM114-Status: GOOD ( 12.15 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 33130ee84164..b7f86f518331 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 24 07:46:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158175 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 59DCB1668 for ; Tue, 24 Sep 2019 07:56:52 +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 312E2207FD for ; Tue, 24 Sep 2019 07:56:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NSi6IQI+"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="lI71P7A7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 312E2207FD 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=6ytwhxkkwJS1ozQt8Tm7r8JxQVZ/dervQGMfyjRHvnE=; b=NSi6IQI+MGXx9k HZXYDzpvgqxJfyi14lI3YnTM+I1ZLxlKJeEdz/+ws+4BB5Frxh0LcbN5Fit5vbJhXQdN2wZOhJaFf IhoyVTK3Ph5/ewadOFW4CDLvYM/Tgogish3S/TzEiDAu7EqxAZY+4VnhET51NhRmR9AfRFEkwbvel YNhCMWbN2E9X/ImLCqhckKeeE9XGPplf2AAuWKcTYKLANGnKlF2eLcggv6Wz+FUSNP8lewEjGeIJh bNGZMU5qmH7oAcIYii78JKVZCRFjZwThnZ5GEX2PrRkNQOhc6reTs16kGGeOv3pIdybVFHKD5+0Vw MO+AudyiZR4v1mW5R/jw==; 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 1iCfgp-0006AM-OV; Tue, 24 Sep 2019 07:56:51 +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 1iCfWz-0004Nr-Ki; Tue, 24 Sep 2019 07:46:45 +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: 3/qdkGvTlkkq/zxW1JR1j4JU6HqizKHXuYFzrHbFR/GUEMykVdtIT819RyZSdoLbNw66igp9Ik tD4aO/Kp8w8gl7l37bShGeyS+qN3CBEBAZbA/3NN03VSxZVTVvdDWpm5qshqUdi/kc/L063m0h 6M0elCTHy4MFm15lGYbqvCNey4UkrGs9R/LfNilbHmN1xuR/qRs4EFZyERwUriGY3mHcMyFteX /DlTPFjamEtaHcwGc23vJwlCEnVNjyQDN8Nat7N7vfFNO1pvBDheejfdNKpz3LMEcV0pd6fteS WuI= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606549" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:40 -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, 24 Sep 2019 00:46:36 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FafDtyDd0pBeBPor9L+sTirrAZhKU1VDZahdjKSKTLLW7rbIHtaxagqRZZRt5GpuueaDSX9fHKg/3/BNGnRbaAc8XIGV4BSAbOlMMQkY8rt9Q2TZcaCGL3mYYtOoiRJC07wZr2TQ7+Kx4iVm+oi0QTgjre5hb7EjpZ+LgZDL5miRiPsrRvOnh1xYJu1BumjmdIE7gnF5PD99g/7BcHMGD6USQAugA+iHe3fiq2qVXhvJ+OfbQcJj8Rxng9EEzNTRYUwBtb0pCJoRbfSUC4BG97FJ1hCtOQ4nBPen7UIOhSNIawjkyctwEK8JTQWZXIG3FxupInWfvNlUFdVoVWS7qQ== 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=iDKYtCC4gPQ07dlYYyP+SuMcIWjm4/q3RdRfwBv3b7Q=; b=YxUDorfhldeYzqnuZu2DzrIDrly1TU26EMy7hPktgIiZO3Ekm5U4W6jYsIuLJra2dpf2Al3XgszoJPFQNoZsn9scVho61P6s+6ee+eU67Is1GpWF0q87aaeap/qe5KvG+rgMEpko2HCJueynyJ8gzi6QVizs1AWUnemT4ZuC4GrBXZHTL6dg6Lso7vz6zBNiZbpZQFMzXAZ5JypOve7ZGlIZxiZtVKD+kQO6P4Bt3abYF6aU8Qvl1Kk8loNowS9e/O0k0wjVQJksTdt5rPSDgQl0CJ2W1kHOJQmCTHIUuHIxvsTxeS2H7bKJua3ZYrcYN2rfKcbB295zuroJ+JU02w== 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=iDKYtCC4gPQ07dlYYyP+SuMcIWjm4/q3RdRfwBv3b7Q=; b=lI71P7A70WcgPXeJ6LTa17bhCKIHQxKNubNeBTIdOH74BbFB5KZWQbnf7J4pcCMcqdG2CdpCDvwNG7in0/2uz96i977vy9Xd7+E1avca7QGmEzv9kUWrDKvCyDLmliFgHgUu8wsqSMEZEbbS0kU1xnkz9UyLzbdjwXaXXpkfu3g= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:35 +0000 From: To: , , , , , Subject: [PATCH v2 13/22] mtd: spi-nor: Void return type for spi_nor_clear_sr/fsr() Thread-Topic: [PATCH v2 13/22] mtd: spi-nor: Void return type for spi_nor_clear_sr/fsr() Thread-Index: AQHVcqwwEs2qvzuVekimP1eUv/eeog== Date: Tue, 24 Sep 2019 07:46:34 +0000 Message-ID: <20190924074533.6618-14-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 1c5b8d65-9f3b-4985-66fe-08d740c352cc x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: bdmNIR6P29KM24AWGH8ibYM9npWndWbjp6zkJ/RxTcVYUeWWy4ntRAFwnPohRVnzKzgZwsqBDHNX6+nM5X2WEuUwGnnNFJBXP3ZxaggdHPO+unwNvP1ElZrKJXhjil0hAe4dGbQ1Uu8UwGzin6w/LS016GiFT085VCBZdoCJvcpsPPApyR8P6zc4tHFFbqGhpvfsWvytLR+c6gBbLYvTQR2i9YnuqatCiQR6+/KKJIaFk50Y4+3V5HERkMPExgR2uemFrKSEsZ+1J34kRkyGm5ovvRr5OPOLYxe1XXk0w1wyP8sp2uOSisSSZoPDkZEjW/cH4OYCULvJml2hoeWeTtn8F1R9GxLACfr7RsjgTXnHSaB/jEBpAoh4WSyIjlAIPRVmTg7M2dWA91rsUyQS4fqxiTtHvxEZVypJb9xdJhw= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1c5b8d65-9f3b-4985-66fe-08d740c352cc X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:34.9911 (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: AjDtkIan7VlCvxsaSG4n1o9Bx6x+/wePkqSSCwhOfFjQ2asVoOx68LiMotSKO6PVMfJa97gtLo00RNnPLmQk/L6k9lDCcjmWven40JjKqD8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004641_792113_8145F10C X-CRM114-Status: GOOD ( 10.53 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 b7f86f518331..191a76c3f7bb 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 24 07:46: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: 11158173 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 74D5413B1 for ; Tue, 24 Sep 2019 07:56:22 +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 5128A20673 for ; Tue, 24 Sep 2019 07:56:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bwsSIjzg"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="cBdKBRwd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5128A20673 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=BRLFEYTquqZQ5cg/vlbYnyEUEAdi95QR1e9FSgCUO00=; b=bwsSIjzgQwwy92 v8EnTovMuN7exg7pDWUgEiv/bt2Vlmo86D5CmGYMnwd9MrD2pLGqZ6iZf+hTymtwy+WJRdE4V51uS O22mB5bJ1/gJNN6HXf/T9vD3QOh+USY3nIC/5jVemwiFlo0mRyB9aUGYAf7jv0ySAcTUy79BV7Svn LW0gpjNen/4p6mmdBucg1iB7+InnePb+8MVLOnf5UlujpPwegSaIqqhkCdjH+iyJdvTL7L+yKnBw7 PG7nskZkXzNjlNODMfpBqHIik8XrSxoePuTchue6VrrSr11hFwSWtjzA76N9LLxSbmvHsebMk7xCz 8ZkbqMewbLc06X3hVJkA==; 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 1iCfgL-0005oN-6w; Tue, 24 Sep 2019 07:56:21 +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 1iCfWy-0004HC-J6; Tue, 24 Sep 2019 07:46:44 +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: WyaAB6vePZ64oyM9HCGficqYY5gscx9j2nPOp7Ibh2gWOpLJBWsimsQgCI4Tb2sl0ZRQ3zFLGH jMtB58e/HtFCIpvELc+wxOfKTj6ONUJXOgE47qoTCFsipFCT5eH1RjDiaPsqBMyITwrjdjzvRd qP3hRDvQUaBAPMnz0ab046yNK9wsaRyl22aMeDY8bN+84KOTxOZugVDQ/l6u1f2VM+YHl96MjN BXwZWswDm1bcY0mZlhROir/Ofwy7oHORk24ymI1U2KnaGwAS88ERaxZ7+aTm/4rd8K2VQNFtil Jew= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066159" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:39 -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, 24 Sep 2019 00:46:39 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WVI3Av6yjWGPXYYdYx5UJaVzOGbFViuRjhPrO64aBMjWOgnJYc5Mw3JsE97hwRs/fDZUOZJEz0XaeWmXtavEJIwIZbL1gIS+8YveTVMctG1dht2yo2oN9plZhLQFmUOD7jPNLM0KBe390w7T1HfPln0TCDibwxrnTbkS0gOIyBQLdhjrzVhb9plntytU24buH6gz+JHWyQXrIzlgpNgJJSnOoe+wG5CUnnG4x0/VExiVUIzcSBTAg0kVoFt66dRowJ53VP8sQ8LxmY/ZYLgHB9GMnW34ZCPfYX4cDv3J2Wkf+/9r1YpV8I1UE64zk3WYwA3mG774vbXsMRLIvFkIJQ== 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=PYZYbHuPFCDOfQWMOdFyoLqrdHxWtzITS85uwXtqQOU=; b=eQfNB+bvYXJ8ut6DKCX7da0o8OuB2B9DGoGiLmSRpQIFPz72M7LvLexWlOHT/Xr4Wd1VFh4b5jnEH5U+qG4ZAKxPh+Kju2jpceJkl07BG0ga2zOFoYtYcaw/x5dhuF8FXbMUXyFJFXyqz3GZz+FVg2lLk2GTqyhrlV4H0Nr22xRo+Rpb6GXf+Ao3ZemdprDNtRlQoEdamy0SDBsfuxOj9Lkdwp+PIY8L2exNBMHaFwgZUu9uAvv0tr+GPxYgkRWYTvadB/gyt+vGAEwPnM/A+VVxjRX0mfUaYvWuCKUWI+8gIOSLyIsb2XG7/+Bmtp+Q8+FTw/+cHwPPRo6MkRhi2w== 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=PYZYbHuPFCDOfQWMOdFyoLqrdHxWtzITS85uwXtqQOU=; b=cBdKBRwdEefknUXatdE94aQXYLfsnoKccOc0Jypvs9ClExE1dd8J+Un++4+9mqnAEMz+SDrM+YplMM4cXpuUp7B0K5ARMYDugBgiPvs9VL11zKErK4mE8Ar76P6db9kJwFEzTALKRzDvfgBYaRGiIoSUbP1g79w47Dy6h7AErMU= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:38 +0000 From: To: , , , , , Subject: [PATCH v2 14/22] mtd: spi-nor: Drop duplicated new line Thread-Topic: [PATCH v2 14/22] mtd: spi-nor: Drop duplicated new line Thread-Index: AQHVcqwyfs9wXyU76EaTMhQ38FDWyg== Date: Tue, 24 Sep 2019 07:46:38 +0000 Message-ID: <20190924074533.6618-15-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 2892f808-34fc-499c-cb23-08d740c354a1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:262; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(4744005)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: /qHikcriA1ge+RA6pKe3cyeZ98rrgequCQvZta4fb5aXvH1SqyBJsLa9GapZP5ItEFTpMaBu3BI+cqHZtxON3HGKBXsDcMwm2HHsAKAwaQtKMtloG5FUuH4Pi0LNdSeYdZu8IJa7OGgeQj+hxzIxauxCEu7ZUFBHc2nleLr5yZf0RAehPmIB4/ZBHcXCdOtEwXJyiQtHNScDJW5GU5WLL8l5Lmh0LKf4548L5vo8fPMaiCIAkcC9XavUVqpIdz+/cjYtQUdygWTNbiBiT9NjDwNp4FynELl/8z8+N4t7R7CG7t3WV1wpbSK9rLeSbAqgeywdmeHCR8ES8LYqHSrVq2EfPKREWUcy+UUkbBm+qETsFgRnO501HkRaspqEAp/s5xz4+R81hY9HMqeJw1xAxurlM4dJVlUUNA0n5kXZ8VA= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2892f808-34fc-499c-cb23-08d740c354a1 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:38.1832 (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: XA4XitCIbfcxmKtkaAhqs0PqQL/wiVaHXwbDc6e8PiGpz6W3eXUwiuPBCJ1v2aSXVujcNYDheCSKTsQsYdeMPgZcHXq/7IutC2Y1ZqtJ5Z4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004640_794920_E8F34C70 X-CRM114-Status: UNSURE ( 7.89 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 191a76c3f7bb..d971f5a4b11f 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 24 07:46: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: 11158181 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 E437913B1 for ; Tue, 24 Sep 2019 07:57:47 +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 BED49207FD for ; Tue, 24 Sep 2019 07:57:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZAqr/RWk"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="OfEpwMbA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BED49207FD 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/TcyVS143sneprH/h62EQ0XBg7Z8OZXPAnSlpY9jlM=; b=ZAqr/RWkTUUfRj Mt42+EE4vP+Wt5oX48h9ZdfzJrdqRSXzd2+IV1up9s9o1DNOC8u6dzueZZk6/4R6AAL/50P9n4iS9 IFO5bJv5YFoNr1ZUOffblQHps4n4aM6GiFpv9yKuJvPhEQ4GnxhICYby1p2nDrjQ2sK8SOB7rRBD8 9IrozgaLxBr18WKCBGbd4wqZpCwINelFDauNAA0ngSAtjGxAIVUfVc++hC6S7mJEv8xrH4Krgu+fa lJC50XF9XGEoQ1unbNwEjM7wX5BNsBnxFsWHTIBLCRNURBaxk0fy+zqYzuWXL6Hxtpo9HEk3FLeD9 xcvVv3RuJ3hxwWK+pFFA==; 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 1iCfhj-0006uU-9l; Tue, 24 Sep 2019 07:57:47 +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 1iCfX3-0004HC-PA; Tue, 24 Sep 2019 07:46:48 +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: lcXwKEPoKAnDCFCzNkzoGOtylOV/oiJR8NoLtcNQQWoHcqMVczI0k2fBo0iESnFfnqBAwGx1TM XceqslJxSEyGKs5Fo0fek5Wk6D5wj5PZqxzBXHXhw2eNg/Iiey/5jdMQCF8gJM5XjLkq8j9MMO ZgfL0dA+qSIOZLHTEbEt8yOhiK/5HlKgZja9ClZhn9AHMMa7Vvetulp/nUHHrmeHYPM5bmUDbl wsrF7SxVupR0Z14bPkBlZwe/Tj0APbiLTsYMRysi4o3kQ2l7NgGFoxESX46lzGR5T7HfibdQKR EbI= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066182" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:45 -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, 24 Sep 2019 00:46:43 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mYr+sZ6FUJw0HfKaVHcQhyt7MvOCmdUKwhR9vVGOts0cNkottBKjZeQxp7jSK4KIECPZsbiIs+saZFfrMROaDelRfJnx3dqjdgl3YWbs6POYCxs+/vaDYFs17xIABwRhpvtyGm60w6wdD5MczACix3rmaOAUz554Fsv8muP/cULKYtj94YNNdQenQgjhv3fH9U8Y0eiSAjsLav//GmgWTdqGhg2PBy4VtlDAWuc64t43gT2ji6bH5MDA8M1f6SQX/wDzKndDitfdmaYsmvnFvI8amZiC/35up6hFgo3qhekcNZxWP3zNqg6QgPUD6nPRjUq91KFHq8QB2X6Wa2Bvwg== 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=u1dAOPK136RfXjG64CR3YRJTj1gmNkkRGBCZ16701yc=; b=JczaWa38dUADlFdNh8bfv0Mafq0QJoUm6rwikd/9NGkc4ukI+1ouFUP45qZinPtRN6X30v0sVjfw7mzFX9XrN7/TATRS9/h5I9AX3J6G/vMKyIdAC5IxqZ9oKUoSQB0nPUbCdKkPpG4r+jLttwuoN4poXSMaIOHH6JcV+gnGPJMwzbNCkPset1cutsZWDr8l8DhGohIe1pz7M6YAxAq2q10+7VjbhYOONzWJAC+CZ5nj8eTb5kL/aQF+JXc9WXB4IMS7ZF6uEXA5DucBRA2NJXr5Tb8Pm6mzgGangSrX80lu3BR7kb2NVoEviVUrwOBZryQ4x5YTQLIgKCyE7e0zew== 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=u1dAOPK136RfXjG64CR3YRJTj1gmNkkRGBCZ16701yc=; b=OfEpwMbAKXCZV9mOhZyelpWVAotPqN+1yZOQF8OKkMhjtYUIJ4NVnwK2AGUjCt5Q/izfYow8Mu1GY2tEuLL1GyJX1NWHDqFxFhM6GhvJPOQBG5JJy2TZZQ1awafQVnVBwPAhKOr1P7/8gfSLqD1Z88n2HohMTSXAVALjTlSJRbY= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:41 +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.2284.023; Tue, 24 Sep 2019 07:46:41 +0000 From: To: , , , , , Subject: [PATCH v2 15/22] mtd: spi-nor: Drop spansion_quad_enable() Thread-Topic: [PATCH v2 15/22] mtd: spi-nor: Drop spansion_quad_enable() Thread-Index: AQHVcqw0rTwdPSINzEqLofiTPWzT3g== Date: Tue, 24 Sep 2019 07:46:41 +0000 Message-ID: <20190924074533.6618-16-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 72065e81-89bf-45a3-5090-08d740c3568b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: Hogk0Fm8KMi6Gm8VDNWXePPMcEGZA8En4kiNQHUMZRCxRQHVcmK6xXJCXW67mYIlvGD5yxuC8alICDMReCRevKQym+tvU0sByEVUcyJx0LtE7J/hGGMbX7H75AJp4uzVsWIoJ1mpQ+/KjjPWlFFcm1Haev3R7w8GJ4TOLW31VWlyPQJp8ZL1vXwM/xFXAqYf5UWIccgcNDbIjY/N793PI6ekDyMMEqV4+fp48FYx4B2QM6JLvjqMk2iorVJXP4OJCZSk1A88DRlK0mlJFiKQHpWOeC3qMK91N+sLoJKZN7ci0UVCzy9SaihCRFVjfUStL0kMUinrW47SBBfQTA3TWJ9/qvDOhlTLAf5srXiIGJ1/xc48F+Y8CFFjwB5Ic/HK47Vtl47xeLEcMYmdB1gT8syUs6+DQUmT1SzpLD3NtcI= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 72065e81-89bf-45a3-5090-08d740c3568b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:41.2934 (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: 4ah3Qr5TuC6ktDmrY693eqvIJBHABCOEdo4bzeITxHxxECo8zGlzpZWGdvjkXLlbLrBua20RW4H8nxudmSxT/ZR+eIBj6T7NZpjPCm3jz3o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004645_918270_C459D0CF X-CRM114-Status: GOOD ( 16.83 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 d971f5a4b11f..668afa9a8c87 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 24 07:46:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 11158185 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 0B11613B1 for ; Tue, 24 Sep 2019 07:58:29 +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 DBA26207FD for ; Tue, 24 Sep 2019 07:58:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iNa6oQeq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="RDD3Hgm7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBA26207FD 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=ibgkg+KS1+u0+pjt2hKj8TiCcxE1Xl8luOHKHIzcxsg=; b=iNa6oQeqc2pVB1 Eq5t+s4xmcTLv1xfVh9hP/1h5naX0YRtPdi7kBiSTcYPMIFxNJMVfzES7rXyOBm7614ai0k+VFTU3 4PNr719zGibjQdd0Mvl+jspXlcSK0P37ZiJFPNGuJeUDdllpHBUO2S1zU0Vnj+i5zQQzjHOtE9W6K R3nhtrp0MXqh8uRvNMo01AJWAuCOXsSKCVGAqvOVeTNmMXIfPdZVWHEkaeQc+Y2jdlbydX0U4fn8Y 7cWgUHGCT5JHf/myOtsuc71xX2XGK/ybg3mVvH5i5QMGeZJjxDLRobjG5i1Rz2AEU5hgho5mdrvgX QTv7FzyeyIUHy4/MrBSQ==; 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 1iCfiJ-0007Qm-DL; Tue, 24 Sep 2019 07:58:23 +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 1iCfX6-0004HC-Oa; Tue, 24 Sep 2019 07:46: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: bdjAl3UPD8OsWsGvbIErvqPj3UQKN2Jut3auqZp65CBKSm+Fap7oWb61Qy4JJb5HuONVJLwbkG 3+rjErLb7J8/DIjwnqkMlOQrzG15N5RYWXXOZ8AlbyYtbdyGa4mI1x5p0JPVIKKYFbga2dnsm4 DjASstyw72ILSkJqtiGTGB0rd8hNoF00LjBcSquzCOuWpJosDXDbvht8nd/F+pSiiB+DVLDpl4 gLFIP5nXxMuDAUq6G9Xj59ZyQpysFcTO4oBS5Cp0MlXFhNyUND9/vARR8TrPER3j/7xP48s3qi HLY= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066195" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:48 -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, 24 Sep 2019 00:46:46 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOqMBTbbekoHXm7GjWJ+FTwLtiqEqMZDJxFdHY1/ErcYs1NmjuC0XUAXMNmMmQ++h3vd5zI/9S5NFit8Z5gZIx8B55ERojtu31VweAI1D/QwA3M1pHSpBO+b0asv4L4coZcljoOylBPzaStr7QdzaaR+PBdJAA2eTm4L31GYe6kthHSBapeKCfKNGAdmhGgM7THuG85Y+Z2A1tnOT5FdPcFY0p7nl4kOQDBGZ82QLno/4nb5OZ9apZzlqhKXax7/12q9JHXlZWVQyQafCj3TeBsI77eoUGjypq/8y9/i4fmjTw5dJnYw25ArR/xl1OcpAnwpjmLDxf/BrFjtsNyUCQ== 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=3/JQqCwKWHa+thZi6BbGu87sx9883Lw02e8xwZUj3VU=; b=fpPZmB2OrwXCj8mYH+kgaptbCtCo6878Mjii/gYxCDab/dxBnHGEJ7Oiz8k7J/J2ruZL74idOaBbRJWGLLnfiRt8AtiItL0bB/LantlSa6Rdjg2O2ljks2u3moQ37Geu9Xma5SkLEKp3nD3Sb7VfIQLfocU7FhfEPwhYaqnqnFzynEREnO5CeVDHsgQzU+cswBhZgZuJ9NnDLuQNzO9uNzDmlHBvoXswPjbKsFR2oBX9FgXJ3wW/KqYOYayBzVeemMkrKUWl61IU3uX/yI7JCpLHGq2Nu15WLn75nEyoIcqAk22F6OGNy95IKkeHsBlEScL9MfnlHTHhVeok+Lq37Q== 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=3/JQqCwKWHa+thZi6BbGu87sx9883Lw02e8xwZUj3VU=; b=RDD3Hgm7CMGrsnkGIn7QjReGPwkL6O5RO2B7vmYeXqB1LYf8eIUAKtudAiAR/J0qD/jpGCcAk7RobpXOREWeyNhR0I347IBjGxI8qQI8Qt2RzjAFldgq8WGQWubPB2UmA8sobvkX8qZWbxWyaJxColWRMtx8lqVUFdBT5BukuyQ= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:44 +0000 From: To: , , , , , Subject: [PATCH v2 16/22] mtd: spi-nor: Fix errno on quad_enable methods Thread-Topic: [PATCH v2 16/22] mtd: spi-nor: Fix errno on quad_enable methods Thread-Index: AQHVcqw22gGmk60ca0uOGGwWABc8zA== Date: Tue, 24 Sep 2019 07:46:44 +0000 Message-ID: <20190924074533.6618-17-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: f65d399c-0f4b-4457-022b-08d740c3586a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: TJo3zOHxezPKwmKSa06kWfh6ul1mfNkCq8ztipZRj7syO2SLx/V4JfXLXoxX45ALOiq2ern1hsc5zKqUMREDeg2thLQvqKElXufXOhBSH5TJ2zsQvBr6cJJzC/iv3DuP7rvBgVWTCimLN3wd1yM7cGiAdv9aRSYXmLFmZAlAoKnsTFqztmAc/hyBQrSIso578TNTac13P0oysBFKqezL8SUtCbBGWZJl8wgdoIAgopRQran8qYFbmmzbTjAC2sR9QaOnmJJKQpsBCFTbYZzx8ZNJUgE8rqB1MbAyU1spKGrCX0A+azVS2UaAbvXeJwlu72I+mRqIzg9r8kJGmA52BsT9L3rHUO40KWiR4rIHlerjESkdNcc/y6VM1NshGPx6yAXam3SkqEt3ALaB/Yq/Cnqj0GnG2ElSwN/7CHnVCHw= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f65d399c-0f4b-4457-022b-08d740c3586a X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:44.4815 (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: ScJrBNdNnjzIXvp/8TkYL9dRgeh2xsR4bw18mqVtTv6Ywm9lfMl8xy4P/sT90f66mvjNllZjf4wyweDLzyNgdUEOYLgRMzfQbTkfy56/9NU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004649_000764_228CB063 X-CRM114-Status: GOOD ( 10.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.154.123 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 668afa9a8c87..6429c855547e 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 24 07:46: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: 11158189 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 554C813B1 for ; Tue, 24 Sep 2019 07:59:04 +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 32607207FD for ; Tue, 24 Sep 2019 07:59:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MtE3KwO/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="iTPyGhDS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32607207FD 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=gL1hyYzsk9CriOQsmjO8n2Z+KUfVxIAzA7Mx+i5MtfQ=; b=MtE3KwO/QL5iM6 Pf4YDTMj1OS8MQ7nKW80N/tEvUfoDlj05BGIN5wc2x6Lqn/dyFpRUIAKC0Gf/GMDcnDAXT9sVd7L3 QIkyngY62VrHthMr0CNxi7kqPJo6ToPx0dGE2UDsoY5U68XQWuUThlxnfJ5AIZA2hP0N5CZZysFh7 +R2IhetHwGn8ShoxqJtQvyqD8PnLNtE5yfIQIBlgmQGtiRvG+JCDGayyXFNRlE2FAD3Hn0nKGxwCz 3HhmPxSuLefirB37ULJyDmpCbPjFZYabVow1BgWj9D4O0F25vLwcGCBoUTvbInPhjssSsuKH2Z/AW cAzhuNYbhoqGnB2B1UMg==; 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 1iCfiw-0007w2-Nq; Tue, 24 Sep 2019 07:59:02 +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 1iCfX9-0004X9-2c; Tue, 24 Sep 2019 07:46:56 +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: yn9SyEcSYkBBLNBKHw1CpGPp8s6Flwxbxz3qA4MPZJuQJBBFr8vGgxBhiw47Q8+zunuLKBqxyj 9xNm4rO7o4h6BHfq22Y90nGXAmv9kGBr0kNoGexisfgPD2vLvwaT44qxxsNrLzJfoZ/DFPjUGK OA/9M4w8ZthK8tDpaxaleMds50AR9kXofo8prqyi8vCRUW8n7SPSWb9IenKvtZTe6jEY6j48vA HSl+ILm9suKSkQybcVpA1o4sQ2a1wQvcgvkJlNB6WeoEqrMnenRUA6kRj1iJAbb5OkY4wPd38G t0M= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066210" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:50 -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, 24 Sep 2019 00:46:49 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TAn/coOfQLs33RXey0oyfiqnoJBTEtPnCi2LuGcCC+4LveoTEd4sz1u+BAXvXNIDNKpvLdvB06E52arECdeN3F6t9X1+SsMMf2Qz+HqYzxgFtzFH2hD1GGUkB284g0vbGxYS0lt07T1LRMZFQF8c/+G0IOBsn4PUGtUH8PKSmE/TwM/WHUgPow73L7I9UmJG02SgxjtHvr/B6QwKqQRkzmcEL2wmOICy8UasRXoVw9uh5z2TC8cTZbDHePyfSCFTbqtqDfBkLMv7n0CfX24g2NfuDAYlpXxGWXZT1FCewZJAUUAsMDcLuJrxvSuQf4siTU7TfaxhMp3N/BAuPf0hHQ== 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=G2o5iROGa2/nMzbRlyxWi6Ag/9MU+bYyU3SOvimX1Dg=; b=HFr3A7vo8aK18m7V0x3qWFQ1+CDnD8HE9Ji+j8TUgoP6D8vo5nLBtuAoXs6dk6lsi+RElweW/b2LoOY3oJEEZNx3XeYfTJ9oG7NZTYb85nOvW5rFPgJkDEC7q6yYd0zOfgwQGgoqts7dO391jVHfrNbTLJ8+jaY2axChDEfv+af0u7fw3fPfu8lrvZBmqaPnfNxTqTpmD4OLYZVGh4LlJsUDZgsJT5fyQ5DBt/I7/uNpdykbutT1nd0Tut1rKz/0HZtrama7mBEai57tcggzdBVYzGqdCTfz4FJpjzFb1NaSSISAwu7IGOcdzaGlUGOFtUp5m/WhvvoM8wNUWqdq3A== 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=G2o5iROGa2/nMzbRlyxWi6Ag/9MU+bYyU3SOvimX1Dg=; b=iTPyGhDS1ycxBdJZOAaWKd5uIlOFfC9DCnH8vGV7HjfndbUYTp+Daoan34u70UVntEgiwP84uAJea2xfPt3sVPW1DTuBhs0PgOrqFd8WRQ00JnfTKb5Lbptwtmd9FcyEArJnm4h4z49SQbj+QAeLy+MHJaoTckdxfP2WubpxI7k= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:47 +0000 From: To: , , , , , Subject: [PATCH v2 17/22] mtd: spi-nor: Check all the bits written, not just the BP ones Thread-Topic: [PATCH v2 17/22] mtd: spi-nor: Check all the bits written, not just the BP ones Thread-Index: AQHVcqw3dowCcvyq1024oXdWsYKuzA== Date: Tue, 24 Sep 2019 07:46:47 +0000 Message-ID: <20190924074533.6618-18-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 2716c3aa-20ab-484f-179a-08d740c35a48 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: VicxnCLdsyMhwib03iNCzCJ7ceqnuKpS6m80Vb749LVDXXhRvBqbmUvXMfUWMLuX1jhRnWZnViaaGgIjkotlYvEAwKIkWNTunlYX7oSSQfMPtYUu0e0WRtLbQPo0E/76AxcGNJVGcy5gi63v0cU86lhxpOsXBz5wB0/FrAnRQREU0VhqlgsPWnayRTdJbfCCMsU6AxlfD9KOIVKK0mQRNYTwpVvfHaTSsCVzpQinI+XokAzE5mgsLdm7NRlUHIYGQ5USzaC7QsONZ4yhyG2H45SNZ2ZvZOtPSDDRNmfq7s/wIO6Tqlt1rsa66EyqHqtzbIgoIt4EoaVJNb+4rpaGwUl9PiwlRvgGGOyqKe/lX1+D5pu3zOy6FOWuB9eDl2nXYLC/vgNy1BYjphIwtKolja1CgGldkY7Y3pUfbKcBYE4= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2716c3aa-20ab-484f-179a-08d740c35a48 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:47.4928 (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: Ut9AA2x27VUnXW19LO2+fdN4H6JIbNKf8hUIPZgYHdhwxg6FoF0VR+T65SN8c4cO8g64URejucS9ViolC4Nbt5wPKQdDr7l7I+R2y9cVndU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004651_183373_DC8645C0 X-CRM114-Status: GOOD ( 10.15 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 Check that all the bits written in the write_sr_and_check() method match the status_new received value. Failing to write the other bits is dangerous too, extend the check. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/spi-nor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 6429c855547e..48bcb2ee1be5 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1493,7 +1493,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) } /* 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) +static int write_sr_and_check(struct spi_nor *nor, u8 status_new) { int ret; @@ -1507,7 +1507,7 @@ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) if (ret) return ret; - return ((nor->bouncebuf[0] & mask) != (status_new & mask)) ? -EIO : 0; + return (nor->bouncebuf[0] != status_new) ? -EIO : 0; } static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, @@ -1673,7 +1673,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 write_sr_and_check(nor, status_new); } /* @@ -1758,7 +1758,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 write_sr_and_check(nor, status_new); } /* From patchwork Tue Sep 24 07:46: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: 11158193 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 691E813B1 for ; Tue, 24 Sep 2019 07:59:35 +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 4364B207FD for ; Tue, 24 Sep 2019 07:59:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SMaznDkF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="U9VxM/rQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4364B207FD 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=uOu2Ou4IxOsNnEiOw6N2/VnQ5dOY6jGOWWIHpBy6WeQ=; b=SMaznDkFCTEa2G XYrQ7mk6Hy46SDPGkopp3vDnH+gL8B3LLJg9F0GBqOKHt5ago4fO/l/hrxaBmRpByseKvwFfaSDxV g6WoiSGk+gyvymqy5GLt7JhOrTIK92wtNHFe2lsDx0L8RizvOmg02UjQaxTpmTLTLIjd0DS7fDZOs n/tbkrC+ncBRVG1XUR8LSxzid+hlU3YWUH3m5Wy3Oxzsr0Fh1PRf7WqG/oGH7M7DKnmlmzQ0eqToR MywSPh+TlHqa4weDKxJaxECfBxB+zMS91ZriEaw25+Wbu2TyliXHSuBHkz1bphA0Pvp2Vfyg9cL1l 1PlPyBhow2zwChD2nmZw==; 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 1iCfjS-0008Oe-Qo; Tue, 24 Sep 2019 07:59:34 +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 1iCfXD-0004aU-DN; Tue, 24 Sep 2019 07:46: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: C/08ldO9TfTripdui/nG8F2VLKxRXke32gdrQXN+yUgTUjT2UPRUuoBf3J72yxtkCBEn5vVFPN ozju5kHK6k8hYi5C6qXevn2PDmA8Zx3UEHezk1QZRbP6UDSjVPZA5Yum9Gg0a34WzIe5kvtA+f M6JOuLjp8MoAyXCTYyJWwnQNecju/UrOVyPMcOw3TMu2xZRKAeaCHGYu+hyC+ct+uH11QV5/NR dxZvROrPvEwYDo0NKLfluYcKwGRrFeU50ubJ9rUJSMTRz9kjan5daNOivMjoob/YJG8bo1slfE q2o= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="50281852" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:54 -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, 24 Sep 2019 00:46:52 -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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:46:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPWnnD6yGTuzxqtm/y3WLoEIakwGlf5/cXRIKcw40JPCQOwVIUyox8mIJg2flSZbmNDM2Bd8KOkaR7aWbW3ppqGeI86+NeILvUtahNpXZmk+cUnvF1tS37+bWPtZ36MTXdw+S3ndf4kpVRDkWLfn31DFl9kNqdaM4whq+Vx4d54IPRcXaCtgpAY3JR06NN8zNNefjSM2jXyvc0nLg7RO71t8/SsBtJiq04Unjf9nwuEyCAS/thLSikLsNykOW6ikkDzhlppmDT/hSKQ8IEVZK7hEvszlwW+dGWgzs3dmOYCDLoBHL28cWQbO8otXOZJsMNZq8QzlRZRgV5QiVMw0fw== 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=TQk2JOlqJszkXyWMTVXKlHc3ol4s39R6XYJvc/hq46U=; b=EaV372oNnAg8BgcdTgd/wBetlSOVo3ytcF5YMNuDriqQeT7DnlmAnLOcjEzpxN7a0IUsmXmxl+oAKH+TBnxAqTAEZzmVVD7Aj5DAtrUiD/XkY+2EjiTwO11hNpixa34yk7Bxbdx2tHdN49nmrv0cBi8FbZjumLW47FG52anXIMT9A+ege3Clkb4o/BJQwOSoormigVseFcerK/lfx8C9gbPwQaC6HHIAAPcFuB/ulA/eS5lIctm3ZYCZHkj0y6nMOJciPnO1p5g28L2VX3p/H1pgLwc3Cx9SDcA2VKBYUX1B7/prSdhENsbufz1Phk0ti/2+KbyljuCBwE601YCNJA== 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=TQk2JOlqJszkXyWMTVXKlHc3ol4s39R6XYJvc/hq46U=; b=U9VxM/rQjoKGwl0YX6oMg4MAILu6tbFflYqbgpZ6ObtojwY2Ypd1CqkVSKC++VVedR0ZMaHhf4qdr8CH0Pro+qy5vCdf/UJUw2yOTq16suKO73PzFfqfiLtQmX/nOlgHoxBUxVyNlmUOlgPKX3eQqhJwtAgCxI9qQkOQqCqLzUM= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:50 +0000 From: To: , , , , , Subject: [PATCH v2 18/22] mtd: spi-nor: Fix clearing of QE bit on lock()/unlock() Thread-Topic: [PATCH v2 18/22] mtd: spi-nor: Fix clearing of QE bit on lock()/unlock() Thread-Index: AQHVcqw53EXz0xlEpUGaAOwjOxtARg== Date: Tue, 24 Sep 2019 07:46:50 +0000 Message-ID: <20190924074533.6618-19-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: e970f92b-21a8-402d-ab24-08d740c35c22 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: r4eS2wvWFfAGUd9Z0MqWm+CbLMXlkU2+LoEGibwVUCXWnm2d5iVAriX3FyQpNXEoLY4LUpH8oJvXlRaqNFBW/D1/m8VW0fQB7/g2O7m0O5/iRrlwWegLQRtpqip63fcXsTi7i/HsCCy9LTeVrZxrVaabD5c+8jwpCGf7M5HqTU4DaxeQvd6GypIKxZtOL+GvyIlCuWwLgwAL9yqQ07/GFYxpgl7fP7rCemc8o4eNr2jREYzLq2LPj6j3sDWUUcURGm5s7okbFoKkRQfELAsTY9F1IJXlIS6af8OqLEamCz+XkkKGGhVe7HRH6XEPBjRKW7xaY/ocMaIsatHKC8tp9Wm8PUNgX9EKrbkDlmNltk8djdNnRXSmMKDHGtumvGfTc9d/CUwNbUuCcoLVUgCKXIRmpFltypn866f9U65HatM= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e970f92b-21a8-402d-ab24-08d740c35c22 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:50.6429 (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: 2rGRvmPs65U52dXkntbDVPmnne3lZSa/7Joakh+/In0qEg+VJPKL9jqKrlmp7sbjrXUWO53z/HdGaiHSCXdS/h0hB6rgqaFg+8p5Xa19aGg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004655_541128_DEB76EE9 X-CRM114-Status: GOOD ( 19.38 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 | 165 +++++++++++++++++++++++++++++++++++++----- include/linux/mtd/spi-nor.h | 2 + 2 files changed, 147 insertions(+), 20 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 48bcb2ee1be5..8ada2003f1c9 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -836,6 +836,127 @@ 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 1 and + * ensure that the byte written match the received value. + * @nor: pointer to a 'struct spi_nor'. + * @sr1: byte value to be written to the Status Register. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_sr1_and_check(struct spi_nor *nor, u8 sr1) +{ + int ret; + + nor->bouncebuf[0] = sr1; + + 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] != sr1) { + dev_err(nor->dev, "SR1: 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 byte written in the Status + * Register 1 match the received value, and that the 16-bit Write did not + * affect what was already in the Status Register 2. + * @nor: pointer to a 'struct spi_nor'. + * @sr1: byte value to be written to the Status Register 1. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1) +{ + 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] = sr1; + + ret = spi_nor_write_sr(nor, sr_cr, 2); + if (ret) + return ret; + + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) + return ret; + + if (sr_cr[0] != sr1) { + dev_err(nor->dev, "SR1: read back test failed\n"); + return -EIO; + } + + if (nor->flags & SNOR_F_NO_READ_CR) + return 0; + + cr_written = sr_cr[1]; + + ret = spi_nor_read_cr(nor, &sr_cr[1]); + if (ret) + return ret; + + if (cr_written != sr_cr[1]) { + dev_err(nor->dev, "CR: read back test failed\n"); + return -EIO; + } + + return 0; +} + +/** + * spi_nor_write_sr_and_check() - Write the Status Register 1 and ensure that + * the byte written match the received value without affecting other bits in the + * Status Register 1 and 2. + * @nor: pointer to a 'struct spi_nor'. + * @sr1: byte value to be written to the Status Register 1. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_sr_and_check(struct spi_nor *nor, u8 sr1) +{ + if (nor->flags & SNOR_F_HAS_16BIT_SR) + return spi_nor_write_16bit_sr_and_check(nor, sr1); + + return spi_nor_write_sr1_and_check(nor, sr1); +} + static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) { return mtd->priv; @@ -1492,24 +1613,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) -{ - 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] != status_new) ? -EIO : 0; -} - static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, uint64_t *len) { @@ -1673,7 +1776,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); + return spi_nor_write_sr_and_check(nor, status_new); } /* @@ -1758,7 +1861,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); + return spi_nor_write_sr_and_check(nor, status_new); } /* @@ -3536,19 +3639,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 +4638,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 24 07:46: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: 11158203 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 969EE13B1 for ; Tue, 24 Sep 2019 08:00:22 +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 715DB207FD for ; Tue, 24 Sep 2019 08:00:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RWyPl0w3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="voXdZDLZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 715DB207FD 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=2bbEYjSBj8WKU+0GyDHLpCCxW/C5BG7AZrHHLDIg+JY=; b=RWyPl0w3S/nraI H9u0TutVy2jEMk+iVEeR6VqfWi4KClk05PCu6OIVYAkev5kimtjfEnFvvWpFqjedHZ7RSpqYSILff 2MpdmGmvRCE11Nx6hyHe3+bt7LBwCrgaJ1l40jCmKnFz2/qzl6LdXUXz6bNlqqaCRFQ9Dqx1zSh8X mH/JA2YdFsC1QnWXhkTYWuMrWIm/UNFkagh6T2VVVkE/AGCUjYKKCNGzhDLF17Ae+haIsOy44+90Z UAHPa7B37LdOSNQghdgAXwleZAX0IiKbH6J9TZgVpCJaKoXYIIcnHoqqipsLqRpcxjHB47ETechwz LYEkrMBbLMYCHbsnByIQ==; 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 1iCfkD-0001k3-Qx; Tue, 24 Sep 2019 08:00:21 +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 1iCfXH-0004cI-C6; Tue, 24 Sep 2019 07:47:03 +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: Hr76gMfbJN+n84Ch1I3DLuL0P9QyNRnChty1LwUC7ZvS2piHLDmwfK24JwWp85J1KgQdqaNRSO SyQ2MwZeZjcF8b3d/YRvjGLfpAgu1dqMPgTg3KI214OOO3BWkxOVO2Iw0fbZoBxFmRzcCzddA4 DUEki7fSzjMVED0/Jw9naJFXAXwhu9kxCV72K3M9v4wgNyDq5e4QQO0CmD4zobvepdVhXualEu CLGW7MXys4UQxBv3b9nbC3KUL2xTxItqzOSCuMUD28LfN9JfnoY15Q7WpSXRoh12xovjojaq16 asI= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="48724269" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:46:56 -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, 24 Sep 2019 00:46:55 -0700 Received: from NAM02-CY1-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, 24 Sep 2019 00:46:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b98OJxfkjGJKm0TcZbDSrgQfj6GLY3TumTiXArkFA2/LFSngAse+WPmSiFkSS8/vkYa87R2ja/T0jiKJN+prxybVC+cvC0owtlALJRkYf4FcKrXmSvk9rbFVRKDaiL5fZ5q0qPbmLsr4604UnKn0U/XkcBARroOzFmy9qC7hnL/jY5xUPAthN0JsVWXLdSJs577yYFDQheBek37VlNEQul4Ko1rzmQ6yAR80orl7rswr1B545xQJj67JqmL03AfjuhCydSifIZyWTp44HUjjJf2Wa0RyJ6mzvr7AJ13YN4OKCOfK2Vub84UgYIuJlgFoofl9x2bbjRUnDsYVLOayow== 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=ba1ut5hlHFjEcBUt735mZVv7gT6ntPLaC/FQzevqd7g=; b=R5r42WLzWJVCuTobT+nLZJOxmXQbAD475+y7cc0IkPxtjfIg70yyDqXfIryGm/Wp09kxuuF6sUv/W71ytSAiy5urE10bUowTfNHBgAY8eXOK0LQKgEo3xdM4CgNCHMbgiEGcAc99rCAuuCPVDX9OOR80Zkr9pCrIwnJDSzZRWfDcI9oErxzS1sbufb8rYst0JxJ018AkhnzFF4yxtDuMpdcG6duvhVDl8cBy84ewKsKar76mkrL/4Czk9Yx+bPgpWHt4+NJybGg2gYcdDTGCVnCj1FG5qSfm2GQZ9ovPj8Ih25I+7n1YTC6qgZDaU2ZEoYYYSEJ777AcKIHutcQwsQ== 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=ba1ut5hlHFjEcBUt735mZVv7gT6ntPLaC/FQzevqd7g=; b=voXdZDLZJ+o0VuUqJaaOGUinP3v7tfzh0rXESsHlfxLpQmBeSTkJu9DzXGcvFytahK2rwoWT/rV61Kn49at8I8+OmyVEJdUNonFQzEPNq422neJtpTcuLWAfh1nTLA6ug1Kz+yl5vvIpV7AqF322dT73F8cg7Kom3DdAiMJYkyI= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46:53 +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.2284.023; Tue, 24 Sep 2019 07:46:53 +0000 From: To: , , , , , Subject: [PATCH v2 19/22] mtd: spi-nor: Rework macronix_quad_enable() Thread-Topic: [PATCH v2 19/22] mtd: spi-nor: Rework macronix_quad_enable() Thread-Index: AQHVcqw7P/9sl7z6ZEKxStZP5t76TA== Date: Tue, 24 Sep 2019 07:46:53 +0000 Message-ID: <20190924074533.6618-20-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 2b037601-84fc-4856-7ad9-08d740c35e05 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: iLMNGg4PVH9HYvqjfkrL+tHFtjEAtDUlcHRx86sejQzRganHRC9tJ4vZbQbVCa25A00GoS7dXSvnoIc7INWnCH86mBoC1H5NtzBBF9DwVDS/KI76xD0LtH0dwAlhV7Eui4Chc7Uxkxxi3i1NmrKg8PZJjWYw816jf1pslhzA5xLlZdwedGM8j0spCLuDcmBPnRlUnyHJwYCSeA4oyE1+BI6TE5rXByiGINqGoxS1coph5NF1QmEp9sCmdzUZbHOCXMCxT+jRXNWG42OwiXhFH4Us7C86xNFMLZfsXR58wKBecXb3DKHupi5Ei8JRvHklIJmWEazixWMeHXGOZbZOYchVVbBhX26nVO8qwGqNvwsSr4k+ayR/HGKtNPzpGPgX25wD+jqdzzfbgJ8q647Hq4v9dXstUDRADxEl+53IHsE= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2b037601-84fc-4856-7ad9-08d740c35e05 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:53.8121 (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: FhbEWtwYk70Xp6lcHql1jNAvZFS0ZVB9hBqSFgOdlU+sDwMIBmy4splJrEsG4L/DBZIN8q70KsjoBB1MYIQlOFmLJHu2EgGpi/vpfilhJc8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004659_623097_FA45BF35 X-CRM114-Status: GOOD ( 14.30 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 8ada2003f1c9..112f93cec7ba 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1933,16 +1933,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; @@ -1950,25 +1949,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]); } /** @@ -2272,7 +2258,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 = { @@ -3656,7 +3642,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: @@ -4553,7 +4539,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 24 07:46: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: 11158217 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 65A9613B1 for ; Tue, 24 Sep 2019 08:01: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 3FAB3207FD for ; Tue, 24 Sep 2019 08:01: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="pck62oW7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="ZWY2C4s8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FAB3207FD 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=twFgmMCg475wtBPcyIlUwh91ScJ4Nbmnu51qjYSo6jw=; b=pck62oW79og/Pl 9o6ofUAYeAnQa+oUv0Yqy6urdE9M9aIIt19LGX6xvIhrIs1VOf0tsaBQ+m0JOoFcsRqsxBSCunK0A HCLl4JCJMsDbnPAvGymS+9P0LguTOGYIUmFr+7JsjBvnbPl1kbKe5PB77EgwrH/X8RrmdsZFjn6OS NOCwvoSGMfcWCI/cyJKbzkMxVet7GSPxSZ4Ja3nekrZrqN/R2wIswH+HWnKmlAYWn144TuhK6S6eX gwFZUAGYdArZ0p8i1zhoWc32aQCaJXbazCjV2caB+p8yvsbcdU8Y5g2s//ATNPXkl09RroPHSOyzi jHxxIH1On3ViGr3m3Amg==; 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 1iCflT-0002ka-UJ; Tue, 24 Sep 2019 08:01:39 +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 1iCfXQ-0004ky-Rr; Tue, 24 Sep 2019 07:47:10 +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: QKYD17TC5pFncjX69zco6JFlP3oxTKOTAB53eYxgAwvHWasiK/JsBPLdH8T4V5LMoTy0iDuH8E p/62bsi/s5u3rtP6ncQ0aAx0ExBcpRp9Av5e+NFnMrn5BSL2Z0H4LtGtJg+PMy1CKpqQMp80Ri DDj1pMdRLAEvCjwjXcjWK8sLqAsDP34Li7oBUBYXxf2bWa+NgSmww8YWNt7GnKMSpj1sCQ0nD0 zVMeM9poiwLe9rTk7fzGIG8SLdgUwWUAt5Dsbm8y0tYob22lQzmicKd9I9lhIXNOFpBOYEJmD9 IgI= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="49066243" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:47: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, 24 Sep 2019 00:46:58 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:46:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XUHnYnIU5xFyc7FdRrFvLI8i98vKf6XlCFmtpXbftRc10rzxlw+uzvOwfOwBgESFXLM/AdA4dmV1kKLswn6E31PdMQEFQhF5xKQLW8iYtc270/xTlJRCcnnvpHSSGyqrLqjBB2SiB4k/+FFUntZfJSH9CMTtXWEmyirvkWON6h3PgcJk40LmFewQsdRnNp9F9GS4VQWaxz+hgDSU3zarK3z5Z0Ls9/ujyrGJ/bbfV2XEUicAZCMFivwr9KZ+cONlDWF1AuFmLgq56v/XwRM7lZGpyz3d3Bo37nzpsEKKT/tXt50rtiYQKCIh3IMWl2X4NMuoQXahzPH4JJuRMCRkbA== 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=HQkXDMU6SeytOoD7GisZLFHNIU2cfAH4FwVbHRJWo5c=; b=cw+AAGyIk71J9/3POtuXdLekM7lw+2GqaRYgGJ7iRpTGNTd1Ax9BkCdrVttKjlgvdfMBHw28GS/ey1HM6o02pvOayx1xEX+tYpAvAjFY/pLNpx1Bg3FJLeAa17U6zmGQwQaI26faTF1EFguek59s0S3zCqY9lufUsWRaPq4rekB4SbWtmQQBCXrvwa7b+PaC7U9f1e5ZoqgAYTDBcV9Rb5Hx9IF2052NxqLJHEJfmxnktEVGFaInXIrB8BC/lbpEsH9VIP2fqiJ9Srtpg/2+JZLb1WtGDwasQfdVXRnSb0K+Py/b3LbIWEdLOLhuQ2w3uODb90qdMiFjaCIGSjJHiA== 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=HQkXDMU6SeytOoD7GisZLFHNIU2cfAH4FwVbHRJWo5c=; b=ZWY2C4s80k0rflLB0qX0wksqJkZm8pNJ/Y7G+3slPUUtXPwNVCEzl/25z/fq/Z4HpMKYT/pArtRIlURou2BfBYi/Hc9eOXDn3oZCL/OX3QTaXglwQwYOBBEB+Rzo20OKfRSOPN74TMUVI3PejV3sRxm6/WlSTiQBpR3WXfSy6Wg= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:46: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.2284.023; Tue, 24 Sep 2019 07:46:57 +0000 From: To: , , , , , Subject: [PATCH v2 20/22] mtd: spi-nor: Rework spansion(_no)_read_cr_quad_enable() Thread-Topic: [PATCH v2 20/22] mtd: spi-nor: Rework spansion(_no)_read_cr_quad_enable() Thread-Index: AQHVcqw9O8wrVibgKkm+8CqFsz6/Jw== Date: Tue, 24 Sep 2019 07:46:56 +0000 Message-ID: <20190924074533.6618-21-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: 27edcb96-9271-444c-304b-08d740c35feb x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: xTo80QZOAf95Nd6iU2eXdpd+LDhYZVFq5Hwayfrn3bTDQcHh0zON62OkKfeuxKLDAXn1bmSKGEww56YBjfv9Mw3bTACwAirwKukvdQ1W1/3PN4xFYJgStJ8uZn0suResfHtppyG9JlHcKsl3isdQIgaA7msO1eLoYK8cuf/CA9skjMClFb8vs0Zde9bhpSdPK0vhOm32oivHqjwQLCpXwwgbNA8c+KoEN35zX9OgOjTz846qb5dDtjQ2cTQztuMQ8kbe59kteILVI+KQuQCeku8p2bOhMRJ/yOP9qXQ4jaeOQ1iFOSsgb9IG+Tz4SGir9Fg7LQkcRY9AcPCp84Xv1rsh6nEeYuRUcAwQBovWB/xp9uN0B7b6gsYkdeS64McQr+wXfZ1T6mjAT4E7gSoGyN+HwV7DZSJ2vNLVuV3HT54= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 27edcb96-9271-444c-304b-08d740c35feb X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:46:56.9632 (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: dG9Cxqe5zdOuLDeO4cfMSUo0/sUTqeLAeyomPykXIVjvU35+sAbPN+wVmzMER7k/TQ9M2EGV1zCuOptyaQ+jSuXIq0yXaUSUutBj73kwFGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004709_167462_DAA6F7AD X-CRM114-Status: GOOD ( 17.74 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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(). Introduce spi_nor_write_16bit_cr_and_check(). The Configuration Register contains bits that can be updated in future: FREEZE, CMP. Provide a generic method that allows updating all bits of the Configuration Register. 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 | 136 +++++++++++++++++++++--------------------- include/linux/mtd/spi-nor.h | 4 +- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 112f93cec7ba..8fd1c04f75d9 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -903,7 +903,7 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1) * 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; } @@ -941,6 +941,59 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1) } /** + * spi_nor_write_16bit_cr_and_check() - Write the Status Register 1 and the + * Configuration Register in one shot. Ensure that the byte written in the + * Configuration Register match the received value, and that the 16-bit Write + * did not affect what was already in the Status Register 1. + * @nor: pointer to a 'struct spi_nor'. + * @cr: byte value to be written to the Configuration Register. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_write_16bit_cr_and_check(struct spi_nor *nor, u8 cr) +{ + int ret; + u8 *sr_cr = nor->bouncebuf; + u8 sr_written; + + /* Keep the current value of the Status Register 1. */ + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) + return ret; + + sr_cr[1] = cr; + + ret = spi_nor_write_sr(nor, sr_cr, 2); + if (ret) + return ret; + + sr_written = sr_cr[0]; + + ret = spi_nor_read_sr(nor, &sr_cr[0]); + if (ret) + return ret; + + if (sr_written != sr_cr[0]) { + dev_err(nor->dev, "SR1: 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 != sr_cr[1]) { + dev_err(nor->dev, "CR: read back test failed\n"); + return -EIO; + } + + return 0; +} + +/** * spi_nor_write_sr_and_check() - Write the Status Register 1 and ensure that * the byte written match the received value without affecting other bits in the * Status Register 1 and 2. @@ -1958,81 +2011,30 @@ 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. + * 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_no_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; - /* 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. - * - * Return: 0 on success, -errno otherwise. - */ -static int spansion_read_cr_quad_enable(struct spi_nor *nor) -{ - u8 *sr_cr = nor->bouncebuf; - int ret; + if (nor->flags & SNOR_F_NO_READ_CR) + return spi_nor_write_16bit_cr_and_check(nor, SR2_QUAD_EN_BIT1); /* Check current Quad Enable bit value. */ - ret = spi_nor_read_cr(nor, &sr_cr[1]); + ret = spi_nor_read_cr(nor, &nor->bouncebuf[0]); if (ret) return ret; - if (sr_cr[1] & CR_QUAD_EN_SPAN) + if (nor->bouncebuf[0] & SR2_QUAD_EN_BIT1) return 0; - sr_cr[1] |= CR_QUAD_EN_SPAN; - - /* 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]); - 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_cr_and_check(nor, nor->bouncebuf[0]); } /** @@ -2112,7 +2114,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. * @@ -2133,7 +2135,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; @@ -3637,7 +3639,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: @@ -3658,7 +3660,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: @@ -4621,7 +4623,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 */ @@ -4839,7 +4841,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 24 07:47: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: 11158211 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 8799713B1 for ; Tue, 24 Sep 2019 08:01:10 +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 645BD214DA for ; Tue, 24 Sep 2019 08:01:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Jp9/xp9Y"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="XucbNqGW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 645BD214DA 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=P24NGzxi8eHOSHckoJVWy4Eif+gV2R+xKBDDzpMAqsE=; b=Jp9/xp9Y8sdQHa qKXpdxBHZniuJmmDRUHgZq7FB9E+rjYZn+ZiwXl7g1aOT6peSqihTnRxZjIaFaxcW7DUpOrt3ipoe SuYs6oEI/zlp0QUPF76/wIT6/EYEX/LmHdfkYm3nYG0WKDc4FJPL2JSESEPoZYmoCLW6HV+iDffL/ 1oLQMfPTEjV1F/Gr4hHRp767XZCIkQ13Loh1vNpxQM57U0sYAeoDQ4mFSMic+WA6/en2SfFdE/Toi UkjeaI9ZbunHIPRD2Kqjj2KqFd970/0Er73R+dWh0irum3NzMwL+3SdfNZ/KDdGA8Ba79n0JNWskr Mqt66vV3P24/Z+4ntcOA==; 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 1iCfky-0002H4-Df; Tue, 24 Sep 2019 08:01:08 +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 1iCfXL-0004fr-6U; Tue, 24 Sep 2019 07:47:07 +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: f+bIJzFgMl9lo6A3SyoxVAtJG1+IaHVM+k0RPzp0GcLQ8rOboe0yxvGvgymxhdOakrNYRG8wW6 SANCIlJp3PpxEaHPgIY7+diZeV6QNBQPzmqaAAQeyzBUPEmvSFVC8CDyuhP5/+oZLYf7mBnouX YXea0HN4yWnA7IBIa//pR+pzNUAXUoa/2ND50+FY5Jk4f8I1j92lhtBG59pnyP23mlJ9JGleYl 9ETWV3GdZUW5yHzTYvwYVyhaCwcR5dJL8wGJVYti6if9HjN2Yw3qIZGPfRAqUmw7ip7NxjCAJG b2Y= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606618" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:47:02 -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, 24 Sep 2019 00:47:01 -0700 Received: from NAM02-BL2-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, 24 Sep 2019 00:47:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QsRTTn12aDDuJMlqXAQ64RE8ilwnuxSzMgaCrPGfyur+XMMtyf9qIfqBjxypMvtb47KdTEDR3ghR1UfhR+0bMFMvkgUcQLSKz+OOBUlYNOkq3cZYRNXoQQ5rYokyaVHVI5enfEqlIEShcQET3FmeE35K4yoRAw2NaY+2t1C2/91qkDbRcHKZjv7/DytctUt2TjbJvSNRGpMZCu23syPbQ8w+N5KW/wLiFOtTKkPRlBrmgYrWL18Sos1fR6zi1clLKU3MlCHM/5LkJZimvHOPXx0+ZJ2kR6IS/KwSFy4TzBYPbJsNqu+lmrygheo9RnrZRu3VKP1wBnHlncuJM93hHA== 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=cz0Ea8zXNjo3GXbLVuGPvWLNLjEA53AIsoQ9wmDJ9aw=; b=WRGNqgtvq0oK3zl9FUYrtbWK37kR8D9MDQ6dVeFo7/ltHj3ToKZV129ogXjPJEOlrvWQeSIx0VaTwAr46FiecAub3FYOfnCHQr5c+Sksl3pB6hVP5JPr/8hhhWDUR8vOPRBrU/VT0T4LWX0oIgP3AZgssZ+hUrv0jo90gX1hgT+DMl3qClk7l/uApHRQxx+f/XBQVWbR4HidnEGSQ5W3KlM1fYKyRgYlxx1Oxk/3O62TTIPCeF59ZQEc6/rRvq0fjvW0lKLweHNW5ygyV0eb6ogbzUnzcli8u282VErqxdrUA50/P5C0pQ25hNGXADu7Cfw2Chf53KmZumfH8mdY7Q== 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=cz0Ea8zXNjo3GXbLVuGPvWLNLjEA53AIsoQ9wmDJ9aw=; b=XucbNqGWJhyNS0ZtZ6y+sl61k+Q/p/ETYUffFJciXJjLfWxkVaOYB6YlXgZN3WkLDuJ8HJX7tWpBwTBX8s6ZH6WHJu/tnPsN6tm4EN7MUq3j0L4Rc3YKp6DnNI8v2+xccIChoG+muuL9Y3niTlgZT6L70WQtKGuWQXWaZnHizZc= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:47: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.2284.023; Tue, 24 Sep 2019 07:47:00 +0000 From: To: , , , , , Subject: [PATCH v2 21/22] mtd: spi-nor: Update sr2_bit7_quad_enable() Thread-Topic: [PATCH v2 21/22] mtd: spi-nor: Update sr2_bit7_quad_enable() Thread-Index: AQHVcqw/7/hvqSeZZk2fV5BDSeD29Q== Date: Tue, 24 Sep 2019 07:47:00 +0000 Message-ID: <20190924074533.6618-22-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: fb1f1616-d389-4068-23df-08d740c361be x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: +G0gmzBE8dgKd0dGH/Rn45M6AHJD8vUFHIzmkFuHjuq3ZDWlQMVkcNLLbfubhI01Kt8wVGmA3BAuPdMdgne/gAymwpBJD8OszTd+eSrHuinzcCHDoTcFFXNnX70rz4oyru1d02sSIwBTt3q4cerTrcMqbB1uSChBi6SAZj/8Bv/dhRXgjCT2GMeKl5bCTSr3G8+jsSF7xNCWLOvTeErHEATuvGaIzoPj591Ke1j2lSnvX8Ju4gNLcwiGTiz+4nKZL0+w0KiB9YyADnq0khe7DGn238lT2QVf4fQXju+2hiUcUhHc9YbE6AazEQq/XF/yi9JmQcpyI7P6ZpjI3Yye0CCv7Em44h77Ju3gOTl98rTNw2wZ3VF/tMT4mQxAmGQ9IEHqYCvrq/UavC2ebIMDCK8/X5kJA7oUNbSUt27KqUo= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: fb1f1616-d389-4068-23df-08d740c361be X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:47:00.0345 (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: 4OnTv/Uw3Yigerlqbghs5kYug3w3zUGVFfWQ89hEWHOfu24M34lImaS8cH4hcJN/VxKCdDMZgIjbrKhXbM2guvLh5qUF+M0VfQycuduYPj0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004703_364276_70CF1F07 X-CRM114-Status: GOOD ( 11.03 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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 8fd1c04f75d9..a53e2cdc564c 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2038,7 +2038,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. @@ -2049,10 +2049,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); @@ -2069,13 +2070,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; } @@ -3649,7 +3652,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 24 07:47: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: 11158219 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 70593912 for ; Tue, 24 Sep 2019 08:01: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 4B89B207FD for ; Tue, 24 Sep 2019 08:01: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="mEvXobx2"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="APOmOxqG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B89B207FD 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=SMseSzoz9QJqSmkbmfc42vCqqPbL7gMyhrQD2JB+cnM=; b=mEvXobx21bJypx OtzLUSOGHWJnbe3+F6DH5cBkVYhMuWdwZPOc4g2FebGrnwoxUIYkYWeyaOnOI9TPvZAh7GV7fAJyR Yb5Z2QmYGH3fP5lUMcUwBVF+gFdjvQlbb1Pv43PI9GFCyQBmyG7p5S1W4AGeaDhe+aEcDKnARr9+q 9sZyRn4DW2uruoPBS5vmCbINf4lggz/5ubJUrwXddXuRDZR6NEZ+ft5xtiufyiZcQp0wdKB0+b0oD efdAKfyLFnx/+ua/tphcScIIY8rxRIxim/wcIopcBvD8s9CfvkOJEXSfc66irnj4MTUY6AjYLWfzv 9vFQ83W+BcKiCKMzYDHw==; 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 1iCflm-00033C-S9; Tue, 24 Sep 2019 08:01:58 +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 1iCfXP-0004fr-IL; Tue, 24 Sep 2019 07:47:11 +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: 2n8fiQ5emTyMj5JDKQ4xsgr4+TuqBORD0EQxunfuoxyt0ZpZ321TCAUI9TTkiOEj0dnbPb6Tt3 k1uS8PLnE+xWsDLwwFFGtf+5pwvtLiegebLYd/NwWWcxKrvXSsUi6lCjMxFakXDrGrEZI6qI8x 9+tjCp2lO4g65j/MqoX9lh7E0WUGwPt6I3c369JVwYptjQPlssPwG33lHAur5IQB2v70Y8DTBL 9uoNPKaUgQGNpg8iVTzJU2UBX1fWlLnPROgHNNloJaAejUrISkBKf+iTHJTOC2GAdDpAJdEc/Y RQg= X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="51606632" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Sep 2019 00:47:06 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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, 24 Sep 2019 00:47:05 -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_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Sep 2019 00:47:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VneQyzS2o4mmEGatOGgWtQ3/fIaKtxfeVFaphNh7l3spGNGqsnJrAXUCn3pLYLmEjWs2nN+HMYcp+e9zMtcL4YLv3F+ek/m/zLU/twfdl2PyEiayoVFb207gHxP0HFWEGZsbV0GW6zvkHcYhiIvCUVbsa2rIxsPwpZAmDNV7UWKGLbMBeM0yyEKVXCKlTd3VxchgCLgslKICh4Vyv6TQETujLziiON9dt4hDLBFd2ThFesWtKMU7V1TtmpNWvSUJIWqiIk57+mGta+w/VClyy+ESEd+P7MECRjGaYXyi10Crb/y0hKEy5f6QxKzib03n7qFvNEhpUAIw/KkovTVstg== 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=kSE1fOq/kdPKPQTHqi+CW+C5tcrir/SqLrGQhykOWio=; b=mc657M8FrPYd+pq2QTCWGzNjn66n1FBZSF6ktflsD/EYvNoFUmxjHsizSpLy2HpWnHxoSe6hlM11fJFR/QPFZNGkcwM4hOXg7yWpGQtD9p8WqD0rpvLFD4ypHIEFEoY/yCByaIj8jhCt9jrkd7RYWMSi8blJgg4aCrA2DynzbAArJ8TkwJlI+dnlsQMH7l4dyBISPk40/aMX8fraQk0WSPuE48hYrrOpSkwU44br998Mwdf9gakthUKUGTEIbZpnBieqU032YXYkbbcsTe0w/PYDGpqtP+u+zoRmNoZ252vrQ5bIM8VF1IPjjhQxNk+y6aWpvQbhbYjzb+0maF9GHw== 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=kSE1fOq/kdPKPQTHqi+CW+C5tcrir/SqLrGQhykOWio=; b=APOmOxqGTPbyNIHaHCkxxS1CfZQKpVaZFqawKZcngfuvR3LMl4GKd2njbTM6n8T+JFVwfGcJOvscEJxLhLYHu+c4OaoLfnfS/8rG6Y51f1pX/r32ayEworrhOizVrtGNYWGVLodWLOy53+1HaZaZMuY9pUViSM/hOsVhU+12S6s= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB4319.namprd11.prod.outlook.com (52.135.39.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26; Tue, 24 Sep 2019 07:47: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.2284.023; Tue, 24 Sep 2019 07:47:03 +0000 From: To: , , , , , Subject: [PATCH v2 22/22] mtd: spi-nor: Rework the disabling of block write protection Thread-Topic: [PATCH v2 22/22] mtd: spi-nor: Rework the disabling of block write protection Thread-Index: AQHVcqxByDKIwNPCUEeLfrkgumi1Aw== Date: Tue, 24 Sep 2019 07:47:03 +0000 Message-ID: <20190924074533.6618-23-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> In-Reply-To: <20190924074533.6618-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:800:1f::50) 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: dbd04d45-b3f4-4fee-9ddd-08d740c36392 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR11MB4319; x-ms-traffictypediagnostic: MN2PR11MB4319: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0170DAF08C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(366004)(396003)(136003)(346002)(39860400002)(376002)(189003)(199004)(14444005)(5660300002)(2201001)(6436002)(256004)(86362001)(11346002)(14454004)(476003)(2501003)(305945005)(186003)(2616005)(26005)(386003)(102836004)(6506007)(25786009)(6486002)(8936002)(81156014)(2906002)(3846002)(81166006)(107886003)(7736002)(8676002)(6512007)(486006)(36756003)(52116002)(71200400001)(71190400001)(50226002)(446003)(66446008)(76176011)(99286004)(66946007)(4326008)(66476007)(64756008)(66556008)(6116002)(54906003)(110136005)(66066001)(316002)(1076003)(7416002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4319; H:MN2PR11MB4448.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: NJMiDS1Vk6Ys0ah7oKbKhSvbfTyJLLFevFl/AU6Ei2svMLiAWx69lZVEoL9g8cwnAxS3xCtWRJiXIiXcrOm8fXl3i7cE+qyKb7FZtYmRZYOuCDLQHiLFWVa7rTV/1C/PL5+mdQuc8Ho4MbEkGcv2VGtNRPajQ7f6utLo2X83hFr47An41C0BVPra6PnXeHTubddkWIt8Ot4yxNQg/H5szOCEeoJolo3bKVHSDR+z644mip0izzCqw52lysWbXQIO1OlB6zoXrE4ko0AMCLL2mZgMtH0l/YxnNP1hbFLT7Z3SbGuWWr5l03WhTbDQqqWc4PgDHBHW2eLvpKj1ElkIK3ZgLuB/+VMRLCjd2JqEOCnkV3byhpe1o02DGRWXW1qytXXLOFeGDQXne7NnfbkIM6L6cmGhwcPRVYeslmD+How= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: dbd04d45-b3f4-4fee-9ddd-08d740c36392 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2019 07:47:03.1047 (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: nRED9qSE2lcIhdOMW7nfpqfjKIRxDNzipAEuDTqk6QOF/gEk27CLmsAQFU9ThePeN2uSzGH7dwpDu0G7+6s/YlhvHTYlaxYuqwkQ4K5otMs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190924_004707_802967_887951A8 X-CRM114-Status: GOOD ( 21.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.147.91 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, 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. The SNOR_F_NO_READ_CR case is treated as well. When the flash doesn't support the CR Read command, we make an assumption about the value of the QE bit. In spi_nor_init(), call spi_nor_quad_enable() first, then spi_nor_unlock_all(), so that at the spi_nor_unlock_all() time we can be sure the QE bit has value one, because of the previous call to spi_nor_quad_enable(). 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 | 146 +++++++++++++++--------------------------- include/linux/mtd/spi-nor.h | 3 - 2 files changed, 51 insertions(+), 98 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index a53e2cdc564c..7b61edf284a1 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2085,79 +2085,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 = { \ @@ -4542,6 +4469,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; @@ -4555,6 +4492,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; @@ -4569,6 +4511,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; @@ -4578,6 +4528,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; @@ -4839,21 +4793,26 @@ static int spi_nor_quad_enable(struct spi_nor *nor) return nor->flash.quad_enable(nor); } -static int spi_nor_init(struct spi_nor *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) { - int err; + if (nor->flags & SNOR_F_HAS_LOCK) + return spi_nor_unlock(&nor->mtd, 0, nor->flash.size); - 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; + return 0; +} - err = nor->clear_sr_bp(nor); - if (err) { - dev_err(nor->dev, - "fail to clear block protection bits\n"); - return err; - } - } +static int spi_nor_init(struct spi_nor *nor) +{ + int err; err = spi_nor_quad_enable(nor); if (err) { @@ -4861,6 +4820,13 @@ static int spi_nor_init(struct spi_nor *nor) 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; + } + if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES)) { /* * If the RESET# pin isn't hooked up properly, or the system @@ -5043,16 +5009,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;