From patchwork Thu Jun 30 09:31:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9207131 X-Patchwork-Delegate: sboyd@codeaurora.org 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 515756089D for ; Thu, 30 Jun 2016 09:40:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D3FA2845E for ; Thu, 30 Jun 2016 09:40:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31809285C3; Thu, 30 Jun 2016 09:40:38 +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=unavailable 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 B55C4284DE for ; Thu, 30 Jun 2016 09:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751575AbcF3JiZ (ORCPT ); Thu, 30 Jun 2016 05:38:25 -0400 Received: from mail-bl2on0083.outbound.protection.outlook.com ([65.55.169.83]:4848 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751601AbcF3JiX (ORCPT ); Thu, 30 Jun 2016 05:38:23 -0400 Received: from BN3PR0301CA0049.namprd03.prod.outlook.com (10.160.152.145) by DM2PR0301MB0861.namprd03.prod.outlook.com (10.160.215.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12; Thu, 30 Jun 2016 09:38:20 +0000 Received: from BY2FFO11OLC012.protection.gbl (2a01:111:f400:7c0c::161) by BN3PR0301CA0049.outlook.office365.com (2a01:111:e400:401e::17) 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; Thu, 30 Jun 2016 09:38:20 +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 BY2FFO11OLC012.mail.protection.outlook.com (10.1.15.23) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Thu, 30 Jun 2016 09:38:19 +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 u5U9cDxF010090; Thu, 30 Jun 2016 02:38:17 -0700 From: Dong Aisheng To: CC: , , , , , , Subject: [PATCH V3 1/8] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Date: Thu, 30 Jun 2016 17:31:11 +0800 Message-ID: <1467279078-2330-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467279078-2330-1-git-send-email-aisheng.dong@nxp.com> References: <1467279078-2330-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131117531003547373; (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)(106466001)(6806005)(575784001)(4326007)(33646002)(8676002)(81156014)(81166006)(2906002)(2351001)(97736004)(87936001)(5003940100001)(2950100001)(229853001)(86362001)(36756003)(48376002)(189998001)(104016004)(77096005)(356003)(8666005)(105606002)(68736007)(50986999)(8936002)(50466002)(19580395003)(85426001)(305945005)(92566002)(7846002)(11100500001)(110136002)(586003)(69596002)(76176999)(47776003)(50226002)(19580405001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0861; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC012; 1:Qzwe24B8DeJ0Ng0wcTTSzdim67VvpHdOr6k5txC30YO8TjehVmU/HG7rg4+6D3qzofkNp7+trsYtDhif+RBhRX852kSoEFuS7tkEKkTSHoHEtkn8BqaeCzLxuaHYy87/7HR8Q5qwRQ7tU04DRXT3L9wxRvv8arhryS8kqjIg6jQZo+/J00sl+sq7qklfwiZMBpvbaQg4jNXKTcFkSaRyiLBFi59l6wsfx8JbapcqamUZR2uOu1uVEjpDAJqrCsCQvpkVorcHtA9qdBTmFQgFyPigZTg/DHqtRKJY+flQZzluTdcipPzew7DkBYvG0sbLb/M7ov6410jves08VGgOb9TtzaY8jhXB4AAClReplzJfOErBZOUKMhMALzzw/LMPno07TNCsMJXXjyflwA7wBXaYS0rQd31rURtBFHti6DuujgubPuuFFF5pAiNlWXtWBVPYqE1khcgzG0fxttpZG20OliUeqMuLl4H3NGDzqwwCTSXYnqFFLd2l9KttlJBJVVdPmG2v50Ri/1BGtjke8B60Q0Gb30EA2uXBaLfh8FmECa/Y4kkFW42d07cgTTjNwX0gWNtSRrEyaLycbaJAAZQzfHPycYSrGYL4z8xnITZ0baF2aCkjDVLv9y1iLgrqZ/cTHEcDGCdvWloDF0268yLvu5DpIoGzjOaGCoVeSy8AWZhAYyapjzTQTdtCBspn3sqgZ7ozaHdvVF5u+sbt7OF9hYKCg6qvIM0r05z5+BU= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 8cc279de-b7f0-4345-eeed-08d3a0ca45c1 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0861; 2:wNbttzjbgZVbXE3e8d2l8DrDP/qEVru4lepp3Ma78kF4y13v1ycNAIveiUeNQcshiSbMs0btWEW1atLeCNM87uodNftfF8t3IlAz2EJSywqHgfAPbwl0h03BsCBpnPKJVWrrUoHRJ8J4/KpWgCEv11bgP4OqLEjZU5Xelw+Lb9CBhdqU6M3P2RHZFnRrQsGf; 3:nx40ab5yOB47lSLisEvk9SxoHL4jFkqnFz6MuahCgvegwN1yTPu8h6HYSEgn/rINHOX/HGQtjJTZJkPLHe6/0RGPxfMSsGBvHk4y6K/TyTJ4Fb8CbW+xN7KnEHE89Z7odrNxYmHqNfSQeSDtRq7cSiyltLJs3SWiwesRaMEAKrLgur9mkKZyrFkytbRDTwR5TDDqbgg4aEZq4xSsJH5lqJwFe7WiQw+u9fGDKODw4Sw=; 25:4Dho7tJmlqb+3lfk+zPLGD5Yg8+8JpACT+AnN5rAlJ1qND7r42c35hby6jME6aHpbFlpGmiw9j0S4iNV80C+DnHNNq9NsSCDCeDDbVvU6dO8r7yi7pYL5+eADJH9ytumcVPioVj4Yo2K8kkuB7c7iHA+rXki7rDen5m6Ob+M/jfRIBw6z3QjAN5HEGla2iUxzrEDWjZkg3hzY/yWmoW4kYvqstp7bJtOqmEoCnP6IylCI6OZkuNcsbeEl2t8an03YhI5Lfd2zWNo90KCFTflDzKNehCMbFHauNeobfvD0c/l5FqRavgDPZZRkvsl89bIij5CesNZN5h9joOlooaN9klO5Z/x/yYOnh6KtG/8YMK6BKUNlJgs0KCb+nRfENfqt0FY61QvTjS2NhSE1In0T7kCQ6zxV0Q2LMz+e4am8Ok= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0861; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13017025)(13015025)(13023025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:DM2PR0301MB0861; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0861; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0861; 4:1eqF3CQJuFsh2ReTH0ij0fbbWlrb88m7h8Us6XyG9TtkV+/vWDqGDInz5WAi/r7n+7bgcMOOQZFhy07CU7nHaHl/Equ0mF50bqwjHev6SAr/OmXcvI4vm0Ytj9YNNmEGc5YfqJ+Ot6g8JoNj7EdAxGY2mVN7ySO5Ut47F3U4DzIhZtLrPFsMyrbRGTyQWWWm253NTZ82K1VEv2RcJB9R7dtB7TFFQilLVnzVyJxzr45QZV2hpwUZV+1Y/a+B7mLkcmg8fwwWK0ilbuiCNyJbA1fzuNFY/M27LseQIXz4QmKmitDvngC2pZYX3d+/jHKeGOkMYiTpH/tV6qqBeriPvScxSUtwSN6c2bftNEkuBX78IrBUnyex9w0Cm3PMlAPtKM5tyD8I4elkmXdzpNLK9cTjtfY6pF5NafpvYqXdf7B3SHz8VhEXnILPzOmtLhLimlaSLYjj6S2j1NIhhIJHP2RYEzMGAhgRwHhnGTWtgGSRerg1er3PLPNskL5B+qSa9ACuXCTE7RDtRrJJzfnbYg== X-Forefront-PRVS: 0989A7979C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0861; 23:yWkJLcN6gRme8nyvXoXOGC6GNzuwGDuJ8eC7qCs?= =?us-ascii?Q?THGxcz1IeyfQssUTvpfDedu40QRHd+bBIxbzJsAj0V8DjHQc2cMV1KVoB2yx?= =?us-ascii?Q?/Inim/SNnBCpM90GfJAYdc2p8VfXmoxcl31asIokws4fnyNI7P8ekziZGf7x?= =?us-ascii?Q?+hvayss3yF2Pv/Rt+KjRr9Po1nJPtlZrW6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8ubodvhHHISoWI4zo0kgFeJvkGY9nYeOV9ryZ+xQKg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2016 09:38:19.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: DM2PR0301MB0861 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)