Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752505AbdLEFwg (ORCPT ); Tue, 5 Dec 2017 00:52:36 -0500 Received: from mail-cys01nam02on0074.outbound.protection.outlook.com ([104.47.37.74]:56345 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752336AbdLEFwT (ORCPT ); Tue, 5 Dec 2017 00:52:19 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Zhiqiang Hou To: , , , , , , , CC: Hou Zhiqiang Subject: [PATCHv2 2/2] mtd: m25p80: restore the status of SPI flash when stop using it Date: Tue, 5 Dec 2017 13:33:22 +0800 Message-ID: <20171205053322.35823-3-Zhiqiang.Hou@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171205053322.35823-1-Zhiqiang.Hou@nxp.com> References: <20171205053322.35823-1-Zhiqiang.Hou@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131569267355478946;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(7966004)(39860400002)(39380400002)(376002)(346002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(77096006)(51416003)(5660300001)(305945005)(356003)(8676002)(50226002)(81156014)(81166006)(97736004)(48376002)(2201001)(50466002)(86362001)(76176011)(8936002)(85426001)(53936002)(68736007)(2950100002)(106466001)(105606002)(189998001)(8656006)(36756003)(104016004)(39060400002)(47776003)(316002)(6666003)(4326008)(2906002)(16586007)(72206003)(110136005)(1076002)(498600001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR03MB2354;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD014;1:+056tZvQTNbvP1EQ6z598Vtq8xPFjiqlIcki146zcEqrYd4hnPW5NJkMv7jVWuhdjsPK7E36qpuZh8Ks7Tt88ohkNtK1XIXffK72bbXlU1i+afjUMNtUcZPPAfMzOiP/ MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a913ed7-efeb-4b19-e09a-08d53ba45678 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603286);SRVR:BN3PR03MB2354; X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB2354;3:n3GDexb6ZeHsnEv4yhSAzcln3jdhdcxZZT2BLMuuFD9Wb54QJ9gIu0VJ2KxjoTQQvw4Wf2xFYXmVZXj0AUVDSkoJxSyZuVuEPnCZNuNCG22PH98GJxPNKsz//h1mCFqqH6uhmj0IQM46VcWui4LDkBQDmSXtsYf6EoPJ0W6UTaEYF96xfEWdtlpuhg3taRnTt7HOnwAEFUawDUNWCAIPP5DWvv1lIBfGg9Bx8rn0dB+J/MnLqa6Jgb0jSIb2+jAaFkF8y93Xp7i+vMV3B90bJAeW4rqWOQkvIcJKCpxpwR2aP/OOhvfwBBO/ZgDGTGVP23ZNoAWgtjZpZdoS11JBFDTBWAZ2e9VD774i+0iUHJ8=;25:CdxmP9LvP2P6kx6aDfdN7RCQJDjoyfTJpK2+hRXK8z3EpyOnZ9Xa5D/lQC6AUNdZxZsDou46QS+WPqrZ6+jSbZS4ASO4nGETISdMsrILoIRigqXoJxwR4SiMVOr396tx7zxkOtTM2EIBvDCGTguTagBqIg6DGKJb351EwLYjEkQPx8KCbCf+da1QqmuRvY70FFgBS+vK2dp0Zx8WSRSnidnwZMU5pGFtWxAvQE8fECC+AswiJ/c+c4lLwBPswrnaiq/djw9XStUJ8wdz8NKkh4fw1kS2U3B4Pw8Ay2E+f7/lo+h0VJ67hhLu0pb8rE8+KzNDap+WwJYdLpKKmPx0WQ== X-MS-TrafficTypeDiagnostic: BN3PR03MB2354: X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB2354;31:PD/o6L4YhBTVtkduJqgAUNCVdLH9MD17YzWpBbOz5gtSoRJmRHtWta7N12h4YPJ/7aonrUAv5PCDxvPa/bcylN+jwWl4f0JMOeDS2Jx4PzHRhVtva6bvHjIhjyHHR1LXmZlYbnU7vuzM8v9EAFVkKE08cM47RMGUG9z6S4tQIBzyo1ndBVlEe+9U693isvUf/k0yVg9xIy+IBj6ZK0kKH7y4qeIto+cCPABg0H9f56o=;4:G83RzDebCdYrh3GqdOjCw7fek3H9AqvEPinyne0woGUgkGo2V649jAuHpaLldcHL9T2R3PmCfGo52vJaJ/FTRQlDwqKt1pBOclFyUYRJUeDsoIViIEFw/f/3E3OrhBTf7pWPhxevqHr48Z/aAQUS/Rcu6v/BjeM1BNogshYetmxuY84l7XQONqNYnyrlCc4YS2LOw4/MADM+rrDSYTw4pLhyL7KHSGzVkYBiAmdsD8um34VUrBxMJg46faR0kje5+oj6vvDoCcIFiC8O8Oc7DPquP5Q0XXSFmiicQf0Qq6C3e+b9sM49nVd7hEH2KoGJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231022)(10201501046)(6055026)(6096035)(20161123561025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123565025)(20161123559100)(20161123556025)(20161123563025)(201708071742011);SRVR:BN3PR03MB2354;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:BN3PR03MB2354; X-Forefront-PRVS: 0512CC5201 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR03MB2354;23:7vKl/JD534CPShjit0PSSmVhF1dcbjl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NXb1VhV2RZEGpGcs+rLo/kaPbEzh9vb4HfalHbl8druF/07kNBeyBflPbtBaGR7ALy6A9vv3RrSTdmnAGXYsxpIloaff0Pq2sQM0uxa/njQ+QWlmEq045ImEf9rBl4rErSpG49qLNu4F598UTJEIX/5aCsWb0Z82BKDbpW0KHCE52ikZqzBN8ezS6lyq4uEIyd1HofOrtHzMx7S/euNufFBMfmjnVpEsU102Pbdm4/4O5Yntc SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2017 05:52:15.2358 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a913ed7-efeb-4b19-e09a-08d53ba45678 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2354 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1283 Lines: 46 From: Hou Zhiqiang Implement .shutdown function to restore the status in reboot process, and add the same operation to the .remove function. Signed-off-by: Hou Zhiqiang --- V2: - Changed code format slightly. drivers/mtd/devices/m25p80.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index dbe6a1de2bb8..a4e18f6aaa33 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -307,10 +307,18 @@ static int m25p_remove(struct spi_device *spi) { struct m25p *flash = spi_get_drvdata(spi); + spi_nor_restore(&flash->spi_nor); + /* Clean up MTD stuff. */ return mtd_device_unregister(&flash->spi_nor.mtd); } +static void m25p_shutdown(struct spi_device *spi) +{ + struct m25p *flash = spi_get_drvdata(spi); + + spi_nor_restore(&flash->spi_nor); +} /* * Do NOT add to this array without reading the following: * @@ -386,6 +394,7 @@ static struct spi_driver m25p80_driver = { .id_table = m25p_ids, .probe = m25p_probe, .remove = m25p_remove, + .shutdown = m25p_shutdown, /* REVISIT: many of these chips have deep power-down modes, which * should clearly be entered on suspend() to minimize power use. -- 2.14.1