From patchwork Wed Jun 29 14:59:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9205573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6392A6075F for ; Wed, 29 Jun 2016 15:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5451E28664 for ; Wed, 29 Jun 2016 15:06:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 485332866E; Wed, 29 Jun 2016 15:06:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8976D28664 for ; Wed, 29 Jun 2016 15:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbcF2PGR (ORCPT ); Wed, 29 Jun 2016 11:06:17 -0400 Received: from mail-bl2on0090.outbound.protection.outlook.com ([65.55.169.90]:43501 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751982AbcF2PGP (ORCPT ); Wed, 29 Jun 2016 11:06:15 -0400 Received: from BN3PR0301CA0021.namprd03.prod.outlook.com (10.160.180.159) by SN2PR03MB1935.namprd03.prod.outlook.com (10.164.114.159) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 29 Jun 2016 15:06:12 +0000 Received: from BN1BFFO11FD046.protection.gbl (2a01:111:f400:7c10::1:175) by BN3PR0301CA0021.outlook.office365.com (2a01:111:e400:4000::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Wed, 29 Jun 2016 15:06:12 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD046.mail.protection.outlook.com (10.58.145.1) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Wed, 29 Jun 2016 15:06:11 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u5TF65JV021502; Wed, 29 Jun 2016 08:06:08 -0700 From: Dong Aisheng To: CC: , , , , , , Subject: [PATCH V2 1/8] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Date: Wed, 29 Jun 2016 22:59:04 +0800 Message-ID: <1467212351-16626-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467212351-16626-1-git-send-email-aisheng.dong@nxp.com> References: <1467212351-16626-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131116863722299200; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(5003940100001)(19580405001)(110136002)(8666005)(76176999)(8676002)(106466001)(48376002)(68736007)(81156014)(2950100001)(77096005)(7846002)(69596002)(305945005)(19580395003)(81166006)(47776003)(8936002)(50466002)(105606002)(50986999)(4326007)(86362001)(36756003)(575784001)(229853001)(586003)(11100500001)(50226002)(2351001)(189998001)(356003)(92566002)(6806005)(87936001)(33646002)(104016004)(97736004)(85426001)(2906002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB1935; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD046; 1:OBevqKrbRWftcQ4v0bAKWz5zHOJtRCvVUewaUrPIXYk8FgtffQ86ZX5+a5nNQvN3zrIEmpY4uc8lW030Q16GkcY2uYhDPFnrD3eg5BBmIkiEAAES+IWwYYBaAlee9F0OjQb3wGAWJMKgLjCLKO2Kyt+2BQ0Gmn8r8jfnTrxx6wpRjI3CHF7AWmJxIwBA+0XsvFWDRKfo6XydbWFXbXnkhw1z2/OOnaD0KOc/l51Xyhmc3BLZo8DFvcytmUdHEzGfubyFx8vQvzkTKTYZEBI1/TCTUj26GTMXspZTvPd9fp5O7hE9wODiYK6mp6ExlzePvD2B+DScgH2UNo+YPFdbQudyYP355yGBz7SPQlQ9BLwtap2uMu6MqV0P3mxIJvui/AiEV9oEtrmvk+g5RZo1rzMJNLJ89ONn09mX62UkQDdCzSZlTMroZDjL/Sg+EvjeopJPcFcB5JMbKG7R6/qcDpwYrUTwdlmSMVJcJ4veAx0sEQ1frG0VD5HRDXWrb3/4v5hhsJuCG6ITO5uUQ82D+WDbfeXlzEZOLpic6bKicQGm5wLiwvucHvMgqfRCIvXds7IJ/pRbTX1lw2qlkbpIGcdZ6QAx8hKZBspDcyhswyu6pyQScWqa1zJpQRzeEpnRjZ8V2JVXZsl/QfZGtirTrh7KFLWQqtLCU9ojDOdN5IcqaSL7GL13Vc7BOB+YlZLqjzrnYIcqdPMiXfiZaYWXkNkWSNYXnwSiHdoFNAthATo= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: ad3af3e5-8f01-490a-1f40-08d3a02ee8b2 X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB1935; 2:kSjX2GLF4DiBXlVvcauA+3OSDEREfga73WdLPMclz7jExQAuP8/Y94O1rZodNwOxc1flliL7VmTG4pqzlOwsjnrOZN+58zmcziUHUncOpGSwCbo8A0YrLuttVUzBuqrImdgH38xD0qZF123WZiyo8SGQYmTo2Js9PtAYO4Yodg06TyFjF58kQXk2cMusYROZ; 3:Zg19VaaMUFYDkn1sXoC5b2zHTJb2MhdMIBo2nWyGucjQ14y61DdYzZQxjZa7qM5ML7kxG8PB9Dbw5hQXuDzYHUjvOIUudd0GfkoRp5aa/RCvsySWmzmlExdnkWA3BGZXGItUDxRosiDMUKF5ylTDcrVB/UjBL4Y4SfIlxzKY7K5SCgB4jzWgCEc80PZsYA89s9C3Yu7bqCaAa5G7GAJl1p61wtadDGji/tgxDlSSP+s=; 25:EnIeX7bMKABExRMORiluds9oPCpZ4s3vpS0FhFRt6Eo3re6GYEWOBZCKztRgbOQrhNlxPziwixHEaeFikxteeSTlTDUWIrUxSJHX8aSb8Xt3rL8mBI9uDZW7j6UW1SMMWjQF+svVC9/+9cLCOV8gxoOleAFSGNm8k4PlRmpnvOnsc3Y71ycIHJ/dRw98QeLUHArbaLYG489OnC1ZmQxOHOiHstvoxMeLpAkcy1RgQM+sKFAX7BUpkRvwor7LPqpj X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB1935; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13023025)(13017025)(13024025)(13015025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:SN2PR03MB1935; BCL:0; PCL:0; RULEID:(400006); SRVR:SN2PR03MB1935; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB1935; 4: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 1; SN2PR03MB1935; 5:KXJX6Vryf9U7PBu+CtI0E9xeGscRstGfZqTFJf0qy6apAMivmmnj6IozVTHjRmVNLTfRQZ/ZCosdM1gS5UW3iiduaWRx8jbeLjh5+fjJnPn86k2iD2sZZsEB2knc10MGGdI5cJBhS+ybK0DxsYY5lqvgmmgebUPkcQx/uKdD5MU=; 24:WbrK98yMvjGlXg9S4KS/tvd5Ybsvgd+EhJNIdDm7jTwRLPlMVwYxK6gdOfNjQQ0qIPKPcqwsb2snWt8gqdgZDcpYXV6DrGb9XB0FnF50Q70= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 15:06:11.9959 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB1935 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This can be useful when clock core wants to enable/disable clocks. Then we don't have to convert the struct clk_core to struct clk to call clk_enable/clk_disable which is a bit un-align with exist using. And after introduce clk_core_{enable|disable}_lock, we can refine clk_enable and clk_disable a bit. As well as clk_core_{enable|disable}_lock, we also added clk_core_{prepare|unprepare}_lock and clk_core_prepare_enable/ clk_core_unprepare_disable for clock core to easily use. Cc: Michael Turquette Cc: Stephen Boyd Cc: Shawn Guo Signed-off-by: Dong Aisheng --- drivers/clk/clk.c | 85 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 95b80aeb8c9d..55e62bac0fb4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -591,6 +591,13 @@ static void clk_core_unprepare(struct clk_core *core) clk_core_unprepare(core->parent); } +static void clk_core_unprepare_lock(struct clk_core *core) +{ + clk_prepare_lock(); + clk_core_unprepare(core); + clk_prepare_unlock(); +} + /** * clk_unprepare - undo preparation of a clock source * @clk: the clk being unprepared @@ -607,9 +614,7 @@ void clk_unprepare(struct clk *clk) if (IS_ERR_OR_NULL(clk)) return; - clk_prepare_lock(); - clk_core_unprepare(clk->core); - clk_prepare_unlock(); + clk_core_unprepare_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_unprepare); @@ -645,6 +650,17 @@ static int clk_core_prepare(struct clk_core *core) return 0; } +static int clk_core_prepare_lock(struct clk_core *core) +{ + int ret; + + clk_prepare_lock(); + ret = clk_core_prepare(core); + clk_prepare_unlock(); + + return ret; +} + /** * clk_prepare - prepare a clock source * @clk: the clk being prepared @@ -659,16 +675,10 @@ static int clk_core_prepare(struct clk_core *core) */ int clk_prepare(struct clk *clk) { - int ret; - if (!clk) return 0; - clk_prepare_lock(); - ret = clk_core_prepare(clk->core); - clk_prepare_unlock(); - - return ret; + return clk_core_prepare_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_prepare); @@ -698,6 +708,15 @@ static void clk_core_disable(struct clk_core *core) clk_core_disable(core->parent); } +static void clk_core_disable_lock(struct clk_core *core) +{ + unsigned long flags; + + flags = clk_enable_lock(); + clk_core_disable(core); + clk_enable_unlock(flags); +} + /** * clk_disable - gate a clock * @clk: the clk being gated @@ -712,14 +731,10 @@ static void clk_core_disable(struct clk_core *core) */ void clk_disable(struct clk *clk) { - unsigned long flags; - if (IS_ERR_OR_NULL(clk)) return; - flags = clk_enable_lock(); - clk_core_disable(clk->core); - clk_enable_unlock(flags); + clk_core_disable_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_disable); @@ -758,6 +773,18 @@ static int clk_core_enable(struct clk_core *core) return 0; } +static int clk_core_enable_lock(struct clk_core *core) +{ + unsigned long flags; + int ret; + + flags = clk_enable_lock(); + ret = clk_core_enable(core); + clk_enable_unlock(flags); + + return ret; +} + /** * clk_enable - ungate a clock * @clk: the clk being ungated @@ -773,19 +800,33 @@ static int clk_core_enable(struct clk_core *core) */ int clk_enable(struct clk *clk) { - unsigned long flags; - int ret; - if (!clk) return 0; - flags = clk_enable_lock(); - ret = clk_core_enable(clk->core); - clk_enable_unlock(flags); + return clk_core_enable_lock(clk->core); +} +EXPORT_SYMBOL_GPL(clk_enable); + +static int clk_core_prepare_enable(struct clk_core *core) +{ + int ret; + + ret = clk_core_prepare_lock(core); + if (ret) + return ret; + + ret = clk_core_enable_lock(core); + if (ret) + clk_core_unprepare_lock(core); return ret; } -EXPORT_SYMBOL_GPL(clk_enable); + +static void clk_core_disable_unprepare(struct clk_core *core) +{ + clk_core_disable_lock(core); + clk_core_unprepare_lock(core); +} static int clk_core_round_rate_nolock(struct clk_core *core, struct clk_rate_request *req)